bugfix: wunlock first, and then release context. (may dead lock)

This commit is contained in:
Cloud Wu
2015-04-18 21:11:57 +08:00
parent 7b783076e5
commit 86d5865457

View File

@@ -77,7 +77,6 @@ skynet_handle_retire(uint32_t handle) {
struct skynet_context * ctx = s->slot[hash]; struct skynet_context * ctx = s->slot[hash];
if (ctx != NULL && skynet_context_handle(ctx) == handle) { if (ctx != NULL && skynet_context_handle(ctx) == handle) {
skynet_context_release(ctx);
s->slot[hash] = NULL; s->slot[hash] = NULL;
ret = 1; ret = 1;
int i; int i;
@@ -92,10 +91,17 @@ skynet_handle_retire(uint32_t handle) {
++j; ++j;
} }
s->name_count = j; s->name_count = j;
} else {
ctx = NULL;
} }
rwlock_wunlock(&s->lock); rwlock_wunlock(&s->lock);
if (ctx) {
// release ctx may call skynet_handle_* , so wunlock first.
skynet_context_release(ctx);
}
return ret; return ret;
} }