mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
double check the message queue when releasing in_global_queue lock
This commit is contained in:
@@ -158,12 +158,18 @@ skynet_context_message_dispatch(void) {
|
||||
|
||||
assert(ctx->in_global_queue);
|
||||
|
||||
int re_q = 1;
|
||||
struct skynet_message msg;
|
||||
if (skynet_mq_pop(q,&msg)) {
|
||||
// empty queue
|
||||
__sync_lock_release(&ctx->in_global_queue);
|
||||
skynet_context_release(ctx);
|
||||
return 0;
|
||||
if (skynet_mq_pop(q,&msg)) {
|
||||
skynet_context_release(ctx);
|
||||
return 0;
|
||||
}
|
||||
if (__sync_lock_test_and_set(&ctx->in_global_queue, 1)) {
|
||||
re_q = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->cb == NULL) {
|
||||
@@ -178,7 +184,9 @@ skynet_context_message_dispatch(void) {
|
||||
|
||||
skynet_context_release(ctx);
|
||||
|
||||
skynet_globalmq_push(q);
|
||||
if (re_q) {
|
||||
skynet_globalmq_push(q);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user