Lines Matching refs:lock

91 			target->lock == cbs->lock &&  in evthread_set_lock_callbacks()
100 if (cbs->alloc && cbs->free && cbs->lock && cbs->unlock) { in evthread_set_lock_callbacks()
155 void *lock; member
165 if (!(result->lock = _original_lock_fns.alloc( in debug_lock_alloc()
171 result->lock = NULL; in debug_lock_alloc()
182 struct debug_lock *lock = lock_; in debug_lock_free() local
183 EVUTIL_ASSERT(lock->count == 0); in debug_lock_free()
184 EVUTIL_ASSERT(locktype == lock->locktype); in debug_lock_free()
186 _original_lock_fns.free(lock->lock, in debug_lock_free()
187 lock->locktype|EVTHREAD_LOCKTYPE_RECURSIVE); in debug_lock_free()
189 lock->lock = NULL; in debug_lock_free()
190 lock->count = -100; in debug_lock_free()
191 mm_free(lock); in debug_lock_free()
195 evthread_debug_lock_mark_locked(unsigned mode, struct debug_lock *lock) in evthread_debug_lock_mark_locked() argument
197 ++lock->count; in evthread_debug_lock_mark_locked()
198 if (!(lock->locktype & EVTHREAD_LOCKTYPE_RECURSIVE)) in evthread_debug_lock_mark_locked()
199 EVUTIL_ASSERT(lock->count == 1); in evthread_debug_lock_mark_locked()
203 if (lock->count > 1) in evthread_debug_lock_mark_locked()
204 EVUTIL_ASSERT(lock->held_by == me); in evthread_debug_lock_mark_locked()
205 lock->held_by = me; in evthread_debug_lock_mark_locked()
212 struct debug_lock *lock = lock_; in debug_lock_lock() local
214 if (lock->locktype & EVTHREAD_LOCKTYPE_READWRITE) in debug_lock_lock()
218 if (_original_lock_fns.lock) in debug_lock_lock()
219 res = _original_lock_fns.lock(mode, lock->lock); in debug_lock_lock()
221 evthread_debug_lock_mark_locked(mode, lock); in debug_lock_lock()
227 evthread_debug_lock_mark_unlocked(unsigned mode, struct debug_lock *lock) in evthread_debug_lock_mark_unlocked() argument
229 if (lock->locktype & EVTHREAD_LOCKTYPE_READWRITE) in evthread_debug_lock_mark_unlocked()
234 EVUTIL_ASSERT(lock->held_by == _evthread_id_fn()); in evthread_debug_lock_mark_unlocked()
235 if (lock->count == 1) in evthread_debug_lock_mark_unlocked()
236 lock->held_by = 0; in evthread_debug_lock_mark_unlocked()
238 --lock->count; in evthread_debug_lock_mark_unlocked()
239 EVUTIL_ASSERT(lock->count >= 0); in evthread_debug_lock_mark_unlocked()
245 struct debug_lock *lock = lock_; in debug_lock_unlock() local
247 evthread_debug_lock_mark_unlocked(mode, lock); in debug_lock_unlock()
249 res = _original_lock_fns.unlock(mode, lock->lock); in debug_lock_unlock()
257 struct debug_lock *lock = _lock; in debug_cond_wait() local
258 EVUTIL_ASSERT(lock); in debug_cond_wait()
260 evthread_debug_lock_mark_unlocked(0, lock); in debug_cond_wait()
261 r = _original_cond_fns.wait_condition(_cond, lock->lock, tv); in debug_cond_wait()
262 evthread_debug_lock_mark_locked(0, lock); in debug_cond_wait()
296 struct debug_lock *lock = lock_; in _evthread_is_debug_lock_held() local
297 if (! lock->count) in _evthread_is_debug_lock_held()
301 if (lock->held_by != me) in _evthread_is_debug_lock_held()
310 struct debug_lock *lock = lock_; in _evthread_debug_get_real_lock() local
311 return lock->lock; in _evthread_debug_get_real_lock()
329 struct debug_lock *lock; in evthread_setup_global_lock_() local
337 lock = mm_malloc(sizeof(struct debug_lock)); in evthread_setup_global_lock_()
338 if (!lock) { in evthread_setup_global_lock_()
342 lock->lock = lock_; in evthread_setup_global_lock_()
343 lock->locktype = locktype; in evthread_setup_global_lock_()
344 lock->count = 0; in evthread_setup_global_lock_()
345 lock->held_by = 0; in evthread_setup_global_lock_()
346 return lock; in evthread_setup_global_lock_()
353 struct debug_lock *lock = lock_; in evthread_setup_global_lock_() local
356 EVUTIL_ASSERT(lock->locktype == locktype); in evthread_setup_global_lock_()
357 EVUTIL_ASSERT(lock->lock == NULL); in evthread_setup_global_lock_()
358 lock->lock = _original_lock_fns.alloc( in evthread_setup_global_lock_()
360 if (!lock->lock) { in evthread_setup_global_lock_()
361 lock->count = -200; in evthread_setup_global_lock_()
362 mm_free(lock); in evthread_setup_global_lock_()
365 return lock; in evthread_setup_global_lock_()
383 _evthreadimpl_lock_free(void *lock, unsigned locktype) in _evthreadimpl_lock_free() argument
386 _evthread_lock_fns.free(lock, locktype); in _evthreadimpl_lock_free()
389 _evthreadimpl_lock_lock(unsigned mode, void *lock) in _evthreadimpl_lock_lock() argument
391 if (_evthread_lock_fns.lock) in _evthreadimpl_lock_lock()
392 return _evthread_lock_fns.lock(mode, lock); in _evthreadimpl_lock_lock()
397 _evthreadimpl_lock_unlock(unsigned mode, void *lock) in _evthreadimpl_lock_unlock() argument
400 return _evthread_lock_fns.unlock(mode, lock); in _evthreadimpl_lock_unlock()
425 _evthreadimpl_cond_wait(void *cond, void *lock, const struct timeval *tv) in _evthreadimpl_cond_wait() argument
428 return _evthread_cond_fns.wait_condition(cond, lock, tv); in _evthreadimpl_cond_wait()
441 return _evthread_lock_fns.lock != NULL; in _evthreadimpl_locking_enabled()