dreid 01/12/17 16:43:22
Modified: locks/beos thread_mutex.c
Log:
We should really be setting the owner of the mutex when we have a
thread_mutex, regardless of whether it's nested. This isn't a big
performance headache on beos thankfully and does allow us to check
the owner for things like conditionals...
This came to light during my experimenting with conditionals for
beos.
Revision Changes Path
1.6 +7 -10 apr/locks/beos/thread_mutex.c
Index: thread_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/beos/thread_mutex.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- thread_mutex.c 2001/12/13 23:43:01 1.5
+++ thread_mutex.c 2001/12/18 00:43:22 1.6
@@ -118,8 +118,9 @@
APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
{
int32 stat;
+ thread_id me = find_thread(NULL);
- if (mutex->nested && mutex->owner == find_thread(NULL)) {
+ if (mutex->nested && mutex->owner == me) {
mutex->owner_ref++;
return APR_SUCCESS;
}
@@ -132,10 +133,8 @@
}
}
- if (mutex->nested) {
- mutex->owner = find_thread(NULL);
- mutex->owner_ref = 1;
- }
+ mutex->owner = me;
+ mutex->owner_ref = 1;
return APR_SUCCESS;
}
@@ -148,7 +147,7 @@
APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
{
int32 stat;
-
+
if (mutex->nested && mutex->owner == find_thread(NULL)) {
mutex->owner_ref--;
if (mutex->owner_ref > 0)
@@ -162,10 +161,8 @@
}
}
- if (mutex->nested) {
- mutex->owner = -1;
- mutex->owner_ref = 0;
- }
+ mutex->owner = -1;
+ mutex->owner_ref = 0;
return APR_SUCCESS;
}