From: Ulrich Drepper Date: Wed, 15 Mar 2000 07:39:53 +0000 (+0000) Subject: (pthread_cond_wait): Check whether mutex is owned by current thread X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e34fe5cf43700463da4e962df2d7ab04a0b3a5bf;p=thirdparty%2Fglibc.git (pthread_cond_wait): Check whether mutex is owned by current thread and return error if not. (pthread_cond_timedwait): Likewise. --- diff --git a/linuxthreads/condvar.c b/linuxthreads/condvar.c index 6f1d758d89a..1d6e930b355 100644 --- a/linuxthreads/condvar.c +++ b/linuxthreads/condvar.c @@ -77,6 +77,10 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) pthread_extricate_if extr; int already_canceled = 0; + /* Check whether the mutex is locked and owned by this thread. */ + if (mutex->__m_owner != self) + return EINVAL; + /* Set up extrication interface */ extr.pu_object = cond; extr.pu_extricate_func = cond_extricate_func; @@ -377,6 +381,10 @@ pthread_cond_timedwait_relative_new(pthread_cond_t *cond, int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec * abstime) { + /* Check whether the mutex is locked and owned by this thread. */ + if (mutex->__m_owner != self) + return EINVAL; + /* Indirect call through pointer! */ return pthread_cond_tw_rel(cond, mutex, abstime); }