summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-04-09 18:16:13 -0400
committerNick Mathewson <nickm@torproject.org>2013-04-26 12:18:07 -0400
commit02fbf68770d3dcb864c867124e159b3680036206 (patch)
tree8d0b931b5f2f6c95386654c9bf3329b80df9c191 /buffer.c
parent9d893c97fa8796e312731f2d0ac0d0336deffdc0 (diff)
downloadlibevent-02fbf68770d3dcb864c867124e159b3680036206.tar.gz
Use finalization feature so bufferevents can avoid deadlocks
Since the bufferevents' events are now EV_FINALIZE (name pending), they won't deadlock. To clean up properly, though, we must use the finalization feature. This patch also split bufferevent deallocation into an "unlink" step that happens fast, and a "destruct" step that happens after finalization. More work is needed: there needs to be a way to specify a finalizer for the bufferevent's argument itself. Also, this finalizer business makes lots of the reference counting we were doing unnecessary. Also, more testing is needed.
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 7c35a69b..860ba0dc 100644
--- a/buffer.c
+++ b/buffer.c
@@ -3345,3 +3345,21 @@ evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb)
}
#endif
+int
+evbuffer_get_callbacks_(struct evbuffer *buffer, struct event_callback **cbs,
+ int max_cbs)
+{
+ int r = 0;
+ EVBUFFER_LOCK(buffer);
+ if (buffer->deferred_cbs) {
+ if (max_cbs < 1) {
+ r = -1;
+ goto done;
+ }
+ cbs[0] = &buffer->deferred;
+ r = 1;
+ }
+done:
+ EVBUFFER_UNLOCK(buffer);
+ return r;
+}