Skip to content

Commit a29c995

Browse files
committed
exit change to parent routine instead of sched -- which greatly improve performance
1 parent b321397 commit a29c995

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/coroutine.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ coroutine_create(coroutine_t *cidp, const void *attr,
7777
getcontext(&ctx->ctx);
7878
ctx->ctx.uc_stack.ss_sp = ctx->stk;
7979
ctx->ctx.uc_stack.ss_size = 8192000;
80-
ctx->ctx.uc_link = &g_exit_coroutine_ctx->ctx;
80+
ctx->ctx.uc_link = &g_coroutine_running_ctx->ctx;
8181
makecontext(&ctx->ctx, (void(*)())start_rtn, 1, arg);
8282

8383
/* add to ready queue */

src/sched.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ coroutine_sched()
131131
list_add_tail(&ctx->queue, &g_coroutine_ready_list);
132132

133133
wqitem_free(item);
134+
}
134135

135-
if (epoll_ctl(g_pollfd, EPOLL_CTL_DEL, fd, event) == -1) {
136-
printf("epoll del error");
137-
exit(-1);
138-
}
136+
if (epoll_ctl(g_pollfd, EPOLL_CTL_DEL, fd, event) == -1) {
137+
perror("epoll del error");
138+
exit(-1);
139139
}
140140

141141
assert(list_empty(&g_fds[fd].wq));
@@ -167,11 +167,11 @@ coroutine_sched()
167167
wqitem_free(item);
168168

169169
cid = ctx->cid;
170+
}
170171

171-
if (epoll_ctl(g_pollfd, EPOLL_CTL_DEL, fd, event) == -1) {
172-
printf("epoll del error");
173-
exit(-1);
174-
}
172+
if (epoll_ctl(g_pollfd, EPOLL_CTL_DEL, fd, event) == -1) {
173+
perror("epoll del error");
174+
exit(-1);
175175
}
176176

177177
assert(list_empty(&g_fds[fd].wq));

0 commit comments

Comments
 (0)