From 25a1f17a167c69a01c8626d697915645314e2bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Wed, 4 Sep 2013 10:49:48 +0800 Subject: [PATCH] remove some unused code --- skynet-src/skynet_start.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/skynet-src/skynet_start.c b/skynet-src/skynet_start.c index f3be84ec..1fa26241 100644 --- a/skynet-src/skynet_start.c +++ b/skynet-src/skynet_start.c @@ -43,10 +43,8 @@ create_thread(pthread_t *thread, void *(*start_routine) (void *), void *arg) { static void wakeup(struct monitor *m, int busy) { if (m->sleep >= m->count - busy) { - if (pthread_mutex_lock(&m->mutex) == 0) { - pthread_cond_signal(&m->cond); - pthread_mutex_unlock(&m->mutex); - } + // signal sleep worker, "spurious wakeup" is harmless + pthread_cond_signal(&m->cond); } } @@ -59,7 +57,6 @@ _socket(void *p) { break; if (r<0) continue; - // FIXME: wakeup will kill some performance when lots of connections wakeup(m,0); } return NULL; @@ -109,9 +106,14 @@ _worker(void *p) { CHECK_ABORT if (pthread_mutex_lock(&m->mutex) == 0) { ++ m->sleep; + // "spurious wakeup" is harmless, + // because skynet_context_message_dispatch() can be call at any time. pthread_cond_wait(&m->cond, &m->mutex); -- m->sleep; - pthread_mutex_unlock(&m->mutex); + if (pthread_mutex_unlock(&m->mutex)) { + fprintf(stderr, "unlock mutex error"); + exit(1); + } } } }