summaryrefslogtreecommitdiff
path: root/bufferevent.c
diff options
context:
space:
mode:
authorTomash Brechko <tomash.brechko@gmail.com>2011-02-24 12:30:40 +0300
committerNick Mathewson <nickm@torproject.org>2011-03-07 21:41:45 -0500
commit5dc566284d736cb692f88685a3bcec70595a7689 (patch)
tree9a1582f781097105df2ca07f4870109c59aac7fc /bufferevent.c
parentab008c7d0588887e88dffd35986005150e5a53e6 (diff)
downloadlibevent-5dc566284d736cb692f88685a3bcec70595a7689.tar.gz
Workaround libevent bug
https://sourceforge.net/tracker/index.php?func=detail&aid=3078187&group_id=50884&atid=461324 The problem is that bufferevent_disable() doesn't disable EV_WRITE when 'connecting' flag is set. However from evhttp_connection_reset() we want to disable EV_WRITE for sure (we are closing the socket next). So we add bufferevent_disable_hard(), which acts like bufferevent_disable(), but resets 'connecting' flag before the call to the actual handler. TODO: bufferevent_disable_hard() shouldn't be public, remove it from event2/bufferevent.h.
Diffstat (limited to 'bufferevent.c')
-rw-r--r--bufferevent.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/bufferevent.c b/bufferevent.c
index 4c9e38fa..9855d183 100644
--- a/bufferevent.c
+++ b/bufferevent.c
@@ -474,6 +474,24 @@ bufferevent_settimeout(struct bufferevent *bufev,
int
+bufferevent_disable_hard(struct bufferevent *bufev, short event)
+{
+ int r = 0;
+ struct bufferevent_private *bufev_private =
+ EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
+
+ BEV_LOCK(bufev);
+ bufev->enabled &= ~event;
+
+ bufev_private->connecting = 0;
+ if (bufev->be_ops->disable(bufev, event) < 0)
+ r = -1;
+
+ BEV_UNLOCK(bufev);
+ return r;
+}
+
+int
bufferevent_disable(struct bufferevent *bufev, short event)
{
int r = 0;