diff --git a/skynet_handle.c b/skynet_handle.c index 6e9f3a0b..51929a52 100644 --- a/skynet_handle.c +++ b/skynet_handle.c @@ -76,18 +76,17 @@ skynet_handle_retire(uint32_t handle) { s->slot[hash] = NULL; int i; - int j=0; - for (i=0;iname_count;i++,j++) { + int j=0, n=s->name_count; + for (i=0; iname[i].handle == handle) { free(s->name[i].name); - ++j; - --s->name_count; - } else { - if (i!=j) { - s->name[i] = s->name[j]; - } + continue; + } else if (i!=j) { + s->name[j] = s->name[i]; } + ++j; } + s->name_count = j; } rwlock_wunlock(&s->lock);