diff --git a/ChangeLog b/ChangeLog index 174075af0a..37d06f020b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Apr 29 10:17:42 2011 KOSAKI Motohiro + + * thread.c (lock_func): small cleanup. + Fri Apr 29 10:07:13 2011 KOSAKI Motohiro * thread.c (rb_mutex_lock, lock_func): Avoid busy loop and diff --git a/thread.c b/thread.c index ae4e669d15..8547ff8738 100644 --- a/thread.c +++ b/thread.c @@ -3235,10 +3235,15 @@ lock_func(rb_thread_t *th, mutex_t *mutex, int timeout_ms) native_mutex_lock(&mutex->lock); th->transition_for_lock = 0; - while (mutex->th || (mutex->th = th, 0)) { + for (;;) { struct timespec ts; int ret; + if (!mutex->th) { + mutex->th = th; + break; + } + mutex->cond_waiting++; if (timeout_ms) { ts = init_lock_timeout(timeout_ms);