diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-01-06 07:20:02 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-01-06 07:20:02 +0000 |
commit | 82db8228ab48498434644bef349042bb9b8d2f14 (patch) | |
tree | f57af9d5e5986a8ae24f981dcb4b5f77721c223b | |
parent | 7e4b33b07e42dc4e9c0530e1afeb56012e56a53c (diff) |
unused var, test lock return
-rw-r--r-- | lib/libc_r/uthread/uthread_once.c | 7 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_once.c | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/libc_r/uthread/uthread_once.c b/lib/libc_r/uthread/uthread_once.c index 27b3a4d594e..a69116bfa33 100644 --- a/lib/libc_r/uthread/uthread_once.c +++ b/lib/libc_r/uthread/uthread_once.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_once.c,v 1.3 1999/11/25 07:01:40 d Exp $ */ +/* $OpenBSD: uthread_once.c,v 1.4 2000/01/06 07:20:01 d Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -39,8 +39,11 @@ int pthread_once(pthread_once_t * once_control, void (*init_routine) (void)) { + int ret; + if (once_control->state == PTHREAD_NEEDS_INIT) { - pthread_mutex_lock(&(once_control->mutex)); + if ((ret = pthread_mutex_lock(&(once_control->mutex))) != 0) + return ret; if (once_control->state == PTHREAD_NEEDS_INIT) { init_routine(); once_control->state = PTHREAD_DONE_INIT; diff --git a/lib/libpthread/uthread/uthread_once.c b/lib/libpthread/uthread/uthread_once.c index 27b3a4d594e..a69116bfa33 100644 --- a/lib/libpthread/uthread/uthread_once.c +++ b/lib/libpthread/uthread/uthread_once.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_once.c,v 1.3 1999/11/25 07:01:40 d Exp $ */ +/* $OpenBSD: uthread_once.c,v 1.4 2000/01/06 07:20:01 d Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -39,8 +39,11 @@ int pthread_once(pthread_once_t * once_control, void (*init_routine) (void)) { + int ret; + if (once_control->state == PTHREAD_NEEDS_INIT) { - pthread_mutex_lock(&(once_control->mutex)); + if ((ret = pthread_mutex_lock(&(once_control->mutex))) != 0) + return ret; if (once_control->state == PTHREAD_NEEDS_INIT) { init_routine(); once_control->state = PTHREAD_DONE_INIT; |