diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-11-27 15:20:43 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-11-27 17:36:24 -0500 |
commit | 347952ffe0039369ff4e7c94c4e27e7333ba8ecb (patch) | |
tree | 51a3147fc57fdfa8290ba880f01068a26f626394 /bufferevent.c | |
parent | e1ffbb82e34d786d07a5acdb16077f6526f610c3 (diff) | |
download | libevent-347952ffe0039369ff4e7c94c4e27e7333ba8ecb.tar.gz |
Revise the locking API: deprecate the old locking callbacks and add trylock.
Previously, there was no good way to request different kinds of lock
(say, read/write vs writeonly or recursive vs nonrecursive), or for a
lock function to signal failure (which would be important for a
trylock mode).
This patch revises the lock API to be a bit more useful. The older
lock calls are still supported for now.
We also add a debugging mode to catch common errors in using the
locking APIs.
Diffstat (limited to 'bufferevent.c')
-rw-r--r-- | bufferevent.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bufferevent.c b/bufferevent.c index 39a062c1..20b2afb0 100644 --- a/bufferevent.c +++ b/bufferevent.c @@ -508,7 +508,8 @@ _bufferevent_decref_and_unlock(struct bufferevent *bufev) BEV_UNLOCK(bufev); if (bufev_private->own_lock) - EVTHREAD_FREE_LOCK(bufev_private->lock); + EVTHREAD_FREE_LOCK(bufev_private->lock, + EVTHREAD_LOCKTYPE_RECURSIVE); /* Free the actual allocated memory. */ mm_free(bufev - bufev->be_ops->mem_offset); @@ -549,7 +550,7 @@ bufferevent_enable_locking(struct bufferevent *bufev, void *lock) BEV_UPCAST(bufev)->lock = lock; BEV_UPCAST(bufev)->own_lock = 0; } else if (!lock) { - EVTHREAD_ALLOC_LOCK(lock); + EVTHREAD_ALLOC_LOCK(lock, EVTHREAD_LOCKTYPE_RECURSIVE); if (!lock) return -1; BEV_UPCAST(bufev)->lock = lock; |