]> granicus.if.org Git - libevent/commitdiff
Send a shutdown(SHUT_WR) before closing an http connection
authorChristopher Davis <chrisd@torproject.org>
Tue, 5 Oct 2010 17:01:54 +0000 (13:01 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 5 Oct 2010 17:01:54 +0000 (13:01 -0400)
This avoids getting an ECONNRESET from the TCP stack.

Fixes bug 2928690

http.c

diff --git a/http.c b/http.c
index d23776eb50aa556afebc4c7fb7e977547ef42908..504e3e41f3a3f6afa184a8eab06b11d7c4209723 100644 (file)
--- a/http.c
+++ b/http.c
@@ -975,8 +975,10 @@ evhttp_connection_free(struct evhttp_connection *evcon)
        if (evcon->bufev != NULL)
                bufferevent_free(evcon->bufev);
 
-       if (evcon->fd != -1)
+       if (evcon->fd != -1) {
+               shutdown(evcon->fd, 1);
                evutil_closesocket(evcon->fd);
+       }
 
        if (evcon->bind_address != NULL)
                mm_free(evcon->bind_address);
@@ -1041,7 +1043,8 @@ evhttp_connection_reset(struct evhttp_connection *evcon)
                /* inform interested parties about connection close */
                if (evhttp_connected(evcon) && evcon->closecb != NULL)
                        (*evcon->closecb)(evcon, evcon->closecb_arg);
-
+               
+               shutdown(evcon->fd, 1);
                evutil_closesocket(evcon->fd);
                evcon->fd = -1;
        }