From: Christopher Davis Date: Tue, 5 Oct 2010 17:01:54 +0000 (-0400) Subject: Send a shutdown(SHUT_WR) before closing an http connection X-Git-Tag: release-2.0.8-rc~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0fd87085d5392039f7406445d1abac47fdde2f5;p=libevent Send a shutdown(SHUT_WR) before closing an http connection This avoids getting an ECONNRESET from the TCP stack. Fixes bug 2928690 --- diff --git a/http.c b/http.c index d23776eb..504e3e41 100644 --- 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; }