]> granicus.if.org Git - libevent/commitdiff
Never call evhttp_readcb while writing.
authorNick Mathewson <nickm@torproject.org>
Thu, 4 Nov 2010 18:05:08 +0000 (14:05 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 4 Nov 2010 18:05:08 +0000 (14:05 -0400)
http.c

diff --git a/http.c b/http.c
index e6b5825c1451ddb8b64cf974b4c2beaa06b2e230..0bde6e32fa0533baeb4577791b249f102799b45f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -343,6 +343,15 @@ evhttp_write_buffer(struct evhttp_connection *evcon,
        evcon->cb_arg = arg;
 
        bufferevent_enable(evcon->bufev, EV_WRITE);
+
+       /* Disable the read callback: we don't actually care about data;
+        * we only care about close detection.  (We don't disable reading,
+        * since we *do* want to learn about any close events.) */
+       bufferevent_setcb(evcon->bufev,
+           NULL, /*read*/
+           evhttp_write_cb,
+           evhttp_error_cb,
+           evcon);
 }
 
 /** Helper: returns true iff evconn is in any connected state. */
@@ -2056,6 +2065,12 @@ evhttp_start_read(struct evhttp_connection *evcon)
        bufferevent_disable(evcon->bufev, EV_WRITE);
        bufferevent_enable(evcon->bufev, EV_READ);
        evcon->state = EVCON_READING_FIRSTLINE;
+       /* Reset the bufferevent callbacks */
+       bufferevent_setcb(evcon->bufev,
+           evhttp_read_cb,
+           evhttp_write_cb,
+           evhttp_error_cb,
+           evcon);
 
        /* If there's still data pending, process it next time through the
         * loop.  Don't do it now; that could get recusive. */