From 06aa9969629d9e45c5bb4db96a21a8920d913c40 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 12 Dec 2002 20:52:56 +0000 Subject: [PATCH] avoid recursive locking in once only function --- src/libCom/osi/os/posix/osdThread.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index 8c62bbc0e..e64fc55f7 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -328,7 +328,12 @@ void epicsThreadOnceOsd(epicsThreadOnceId *id, void (*func)(void *), void *arg) } if (*id == 0) { /* 0 => first call */ *id = -1; /* -1 => func() active */ - func(arg); + /* avoid recursive locking */ + status = pthread_mutex_unlock(&onceLock); + checkStatusQuit(status,"pthread_mutex_unlock","epicsThreadOnceOsd"); + func(arg); + status = pthread_mutex_lock(&onceLock); + checkStatusQuit(status,"pthread_mutex_lock","epicsThreadOnceOsd"); *id = +1; /* +1 => func() done (see epicsThreadOnce() macro defn) */ } status = pthread_mutex_unlock(&onceLock);