mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (mutex_try_lock): check and set owner thread.
* thread_pthread.ci: fix to show error code in error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e0943c481a
commit
0089455e53
3 changed files with 17 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Apr 12 17:13:22 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* thread.c (mutex_try_lock): check and set owner thread.
|
||||
|
||||
* thread_pthread.ci: fix to show error code in error message.
|
||||
|
||||
Thu Apr 12 17:11:54 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* eval.c (rb_rescue2): restore cfp ([ruby-dev:30582]).
|
||||
|
|
5
thread.c
5
thread.c
|
@ -2138,7 +2138,12 @@ mutex_try_lock(VALUE self)
|
|||
mutex_t *mutex;
|
||||
GetMutexVal(self, mutex);
|
||||
|
||||
if (mutex->th == GET_THREAD()) {
|
||||
rb_raise(rb_eThreadError, "deadlock; recursive locking");
|
||||
}
|
||||
|
||||
if (native_mutex_trylock(&mutex->lock) != EBUSY) {
|
||||
mutex->th = GET_THREAD();
|
||||
return Qtrue;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -48,16 +48,18 @@ native_mutex_trylock(pthread_mutex_t *lock)
|
|||
void
|
||||
native_mutex_initialize(pthread_mutex_t *lock)
|
||||
{
|
||||
if (pthread_mutex_init(lock, 0) != 0) {
|
||||
rb_bug("native_mutex_initialize return non-zero");
|
||||
int r = pthread_mutex_init(lock, 0);
|
||||
if (r != 0) {
|
||||
rb_bug("native_mutex_initialize return non-zero: %d", r);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
native_mutex_destroy(pthread_mutex_t *lock)
|
||||
{
|
||||
if (pthread_mutex_destroy(lock) != 0) {
|
||||
rb_bug("native_mutex_destroy return non-zero");
|
||||
int r = pthread_mutex_destroy(lock);
|
||||
if (r != 0) {
|
||||
rb_bug("native_mutex_destroy return non-zero: %d", r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue