summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-09-22 14:51:53 -0700
committerWink Saville <wink@google.com>2010-09-22 14:51:53 -0700
commitb9e49ad56e5776ace7c6eab2e997d5b7acb16792 (patch)
treec0e2ba58abab835fb00e89509a8922297038bdcf
parentfedbcde6ef552e84bf7ce7598bca7dddf1722d6a (diff)
downloadbionic-b9e49ad56e5776ace7c6eab2e997d5b7acb16792.zip
bionic-b9e49ad56e5776ace7c6eab2e997d5b7acb16792.tar.gz
bionic-b9e49ad56e5776ace7c6eab2e997d5b7acb16792.tar.bz2
Use a recursive lock for pthread_once. DO NOT MERGE.
Backport change I9fc8b790 from Master to Gingerbread Change-Id: I5cf48fcd4efb7991ed82f87d9365c19655dc9b7f
-rw-r--r--libc/bionic/pthread.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index e21a1f9..b28cd9f 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -1866,15 +1866,15 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
*/
int pthread_once( pthread_once_t* once_control, void (*init_routine)(void) )
{
- static pthread_mutex_t once_lock = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_mutex_t once_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
if (*once_control == PTHREAD_ONCE_INIT) {
- _normal_lock( &once_lock );
+ pthread_mutex_lock( &once_lock );
if (*once_control == PTHREAD_ONCE_INIT) {
(*init_routine)();
*once_control = ~PTHREAD_ONCE_INIT;
}
- _normal_unlock( &once_lock );
+ pthread_mutex_unlock( &once_lock );
}
return 0;
}