summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-07-02 02:05:23 +0000
committermtm <mtm@FreeBSD.org>2003-07-02 02:05:23 +0000
commit31f6d3ff92de773057286bc54965b8528af415ae (patch)
tree5fa6b7704ff296c0afe2679996b6778ff54553de /lib/libthr
parent8701d3b8e4785a0a7ce32e081947393b3dcb1ae1 (diff)
downloadFreeBSD-src-31f6d3ff92de773057286bc54965b8528af415ae.zip
FreeBSD-src-31f6d3ff92de773057286bc54965b8528af415ae.tar.gz
Begin making libthr async signal safe.
Create a private, single underscore, version of pthread_mutex_unlock for libc. pthread_mutex_lock already has one. These versions are different from the ones that applications will link against because they block all signals from the time a call to lock the mutex is made until it is successfully unlocked.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_mutex.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 3244158..ee615c3 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -85,11 +85,11 @@ static pthread_mutexattr_t static_mattr = &static_mutex_attr;
/* Single underscore versions provided for libc internal usage: */
__weak_reference(__pthread_mutex_trylock, pthread_mutex_trylock);
__weak_reference(__pthread_mutex_lock, pthread_mutex_lock);
+__weak_reference(__pthread_mutex_unlock, pthread_mutex_unlock);
/* No difference between libc and application usage of these: */
__weak_reference(_pthread_mutex_init, pthread_mutex_init);
__weak_reference(_pthread_mutex_destroy, pthread_mutex_destroy);
-__weak_reference(_pthread_mutex_unlock, pthread_mutex_unlock);
/*
@@ -505,6 +505,9 @@ __pthread_mutex_lock(pthread_mutex_t *mutex)
return (ret);
}
+/*
+ * Libc internal.
+ */
int
_pthread_mutex_lock(pthread_mutex_t *mutex)
{
@@ -513,6 +516,8 @@ _pthread_mutex_lock(pthread_mutex_t *mutex)
if (_thread_initial == NULL)
_thread_init();
+ _thread_sigblock();
+
if (mutex == NULL)
ret = EINVAL;
@@ -524,15 +529,30 @@ _pthread_mutex_lock(pthread_mutex_t *mutex)
((ret = mutex_init(mutex, 1)) == 0))
ret = mutex_lock_common(mutex, 0);
+ if (ret != 0)
+ _thread_sigunblock();
+
return (ret);
}
int
-_pthread_mutex_unlock(pthread_mutex_t * mutex)
+__pthread_mutex_unlock(pthread_mutex_t * mutex)
{
return (mutex_unlock_common(mutex, /* add reference */ 0));
}
+/*
+ * Libc internal
+ */
+int
+_pthread_mutex_unlock(pthread_mutex_t * mutex)
+{
+ int error;
+ if ((error = mutex_unlock_common(mutex, /* add reference */ 0)) == 0)
+ _thread_sigunblock();
+ return (error);
+}
+
int
_mutex_cv_unlock(pthread_mutex_t * mutex)
{
OpenPOWER on IntegriCloud