summaryrefslogtreecommitdiff
path: root/bufferevent.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-08-24 21:39:28 -0400
committerNick Mathewson <nickm@torproject.org>2011-08-28 14:39:12 -0400
commite6af35d762822e56e97cca3708ffee291c867d20 (patch)
treeff4499e205590b1ca543e9a2c6d86e8dbe75efbc /bufferevent.c
parent0ff2c5a92246083495ff4d672372b8afe510105b (diff)
downloadlibevent-e6af35d762822e56e97cca3708ffee291c867d20.tar.gz
Correctly terminate IO on an async bufferevent on bufferevent_free
Diffstat (limited to 'bufferevent.c')
-rw-r--r--bufferevent.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/bufferevent.c b/bufferevent.c
index 9855d183..93a08015 100644
--- a/bufferevent.c
+++ b/bufferevent.c
@@ -59,6 +59,9 @@
#include "evbuffer-internal.h"
#include "util-internal.h"
+static void _bufferevent_cancel_all(struct bufferevent *bev);
+
+
void
bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
{
@@ -674,6 +677,7 @@ bufferevent_free(struct bufferevent *bufev)
{
BEV_LOCK(bufev);
bufferevent_setcb(bufev, NULL, NULL, NULL, NULL);
+ _bufferevent_cancel_all(bufev);
_bufferevent_decref_and_unlock(bufev);
}
@@ -750,6 +754,17 @@ bufferevent_getfd(struct bufferevent *bev)
return (res<0) ? -1 : d.fd;
}
+static void
+_bufferevent_cancel_all(struct bufferevent *bev)
+{
+ union bufferevent_ctrl_data d;
+ memset(&d, 0, sizeof(d));
+ BEV_LOCK(bev);
+ if (bev->be_ops->ctrl)
+ bev->be_ops->ctrl(bev, BEV_CTRL_CANCEL_ALL, &d);
+ BEV_UNLOCK(bev);
+}
+
short
bufferevent_get_enabled(struct bufferevent *bufev)
{