Lines 26-31
Link Here
|
26 |
#include <shlib-compat.h> |
26 |
#include <shlib-compat.h> |
27 |
#include <stap-probe.h> |
27 |
#include <stap-probe.h> |
28 |
|
28 |
|
|
|
29 |
#include "cond-lock.h" |
30 |
|
29 |
struct _condvar_cleanup_buffer |
31 |
struct _condvar_cleanup_buffer |
30 |
{ |
32 |
{ |
31 |
int oldtype; |
33 |
int oldtype; |
Lines 46-52
__condvar_cleanup (void *arg)
Link Here
|
46 |
? LLL_SHARED : LLL_PRIVATE; |
48 |
? LLL_SHARED : LLL_PRIVATE; |
47 |
|
49 |
|
48 |
/* We are going to modify shared data. */ |
50 |
/* We are going to modify shared data. */ |
49 |
lll_lock (cbuffer->cond->__data.__lock, pshared); |
51 |
cond_lock (cbuffer->cond, pshared); |
50 |
|
52 |
|
51 |
if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq) |
53 |
if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq) |
52 |
{ |
54 |
{ |
Lines 77-83
__condvar_cleanup (void *arg)
Link Here
|
77 |
} |
79 |
} |
78 |
|
80 |
|
79 |
/* We are done. */ |
81 |
/* We are done. */ |
80 |
lll_unlock (cbuffer->cond->__data.__lock, pshared); |
82 |
cond_unlock (cbuffer->cond, pshared); |
81 |
|
83 |
|
82 |
/* Wake everybody to make sure no condvar signal gets lost. */ |
84 |
/* Wake everybody to make sure no condvar signal gets lost. */ |
83 |
if (! destroying) |
85 |
if (! destroying) |
Lines 115-127
__pthread_cond_wait (cond, mutex)
Link Here
|
115 |
LIBC_PROBE (cond_wait, 2, cond, mutex); |
117 |
LIBC_PROBE (cond_wait, 2, cond, mutex); |
116 |
|
118 |
|
117 |
/* Make sure we are alone. */ |
119 |
/* Make sure we are alone. */ |
118 |
lll_lock (cond->__data.__lock, pshared); |
120 |
cond_lock (cond, pshared); |
119 |
|
121 |
|
120 |
/* Now we can release the mutex. */ |
122 |
/* Now we can release the mutex. */ |
121 |
err = __pthread_mutex_unlock_usercnt (mutex, 0); |
123 |
err = __pthread_mutex_unlock_usercnt (mutex, 0); |
122 |
if (__glibc_unlikely (err)) |
124 |
if (__glibc_unlikely (err)) |
123 |
{ |
125 |
{ |
124 |
lll_unlock (cond->__data.__lock, pshared); |
126 |
cond_unlock (cond, pshared); |
125 |
return err; |
127 |
return err; |
126 |
} |
128 |
} |
127 |
|
129 |
|
Lines 156-162
__pthread_cond_wait (cond, mutex)
Link Here
|
156 |
{ |
158 |
{ |
157 |
unsigned int futex_val = cond->__data.__futex; |
159 |
unsigned int futex_val = cond->__data.__futex; |
158 |
/* Prepare to wait. Release the condvar futex. */ |
160 |
/* Prepare to wait. Release the condvar futex. */ |
159 |
lll_unlock (cond->__data.__lock, pshared); |
161 |
cond_unlock (cond, pshared); |
160 |
|
162 |
|
161 |
/* Enable asynchronous cancellation. Required by the standard. */ |
163 |
/* Enable asynchronous cancellation. Required by the standard. */ |
162 |
cbuffer.oldtype = __pthread_enable_asynccancel (); |
164 |
cbuffer.oldtype = __pthread_enable_asynccancel (); |
Lines 190-196
__pthread_cond_wait (cond, mutex)
Link Here
|
190 |
__pthread_disable_asynccancel (cbuffer.oldtype); |
192 |
__pthread_disable_asynccancel (cbuffer.oldtype); |
191 |
|
193 |
|
192 |
/* We are going to look at shared data again, so get the lock. */ |
194 |
/* We are going to look at shared data again, so get the lock. */ |
193 |
lll_lock (cond->__data.__lock, pshared); |
195 |
cond_lock (cond, pshared); |
194 |
|
196 |
|
195 |
/* If a broadcast happened, we are done. */ |
197 |
/* If a broadcast happened, we are done. */ |
196 |
if (cbuffer.bc_seq != cond->__data.__broadcast_seq) |
198 |
if (cbuffer.bc_seq != cond->__data.__broadcast_seq) |
Lines 216-222
__pthread_cond_wait (cond, mutex)
Link Here
|
216 |
lll_futex_wake (&cond->__data.__nwaiters, 1, pshared); |
218 |
lll_futex_wake (&cond->__data.__nwaiters, 1, pshared); |
217 |
|
219 |
|
218 |
/* We are done with the condvar. */ |
220 |
/* We are done with the condvar. */ |
219 |
lll_unlock (cond->__data.__lock, pshared); |
221 |
cond_unlock (cond, pshared); |
220 |
|
222 |
|
221 |
/* The cancellation handling is back to normal, remove the handler. */ |
223 |
/* The cancellation handling is back to normal, remove the handler. */ |
222 |
__pthread_cleanup_pop (&buffer, 0); |
224 |
__pthread_cleanup_pop (&buffer, 0); |