diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-04-09 18:16:13 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-26 12:18:07 -0400 |
commit | 02fbf68770d3dcb864c867124e159b3680036206 (patch) | |
tree | 8d0b931b5f2f6c95386654c9bf3329b80df9c191 /bufferevent_async.c | |
parent | 9d893c97fa8796e312731f2d0ac0d0336deffdc0 (diff) | |
download | libevent-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 'bufferevent_async.c')
-rw-r--r-- | bufferevent_async.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/bufferevent_async.c b/bufferevent_async.c index 83b5c141..0152fd16 100644 --- a/bufferevent_async.c +++ b/bufferevent_async.c @@ -93,6 +93,7 @@ const struct bufferevent_ops bufferevent_ops_async = { evutil_offsetof(struct bufferevent_async, bev.bev), be_async_enable, be_async_disable, + NULL, /* Unlink */ be_async_destruct, bufferevent_generic_adj_timeouts_, be_async_flush, @@ -384,11 +385,6 @@ be_async_destruct(struct bufferevent *bev) /* XXXX possible double-close */ evutil_closesocket(fd); } - /* delete this in case non-blocking connect was used */ - if (event_initialized(&bev->ev_write)) { - event_del(&bev->ev_write); - bufferevent_del_generic_timeout_cbs_(bev); - } } /* GetQueuedCompletionStatus doesn't reliably yield WSA error codes, so |