mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Send a shutdown(SHUT_WR) before closing an http connection
This avoids getting an ECONNRESET from the TCP stack. Fixes bug 2928690
This commit is contained in:
parent
0faaee0165
commit
e0fd87085d
5
http.c
5
http.c
@ -975,8 +975,10 @@ evhttp_connection_free(struct evhttp_connection *evcon)
|
|||||||
if (evcon->bufev != NULL)
|
if (evcon->bufev != NULL)
|
||||||
bufferevent_free(evcon->bufev);
|
bufferevent_free(evcon->bufev);
|
||||||
|
|
||||||
if (evcon->fd != -1)
|
if (evcon->fd != -1) {
|
||||||
|
shutdown(evcon->fd, 1);
|
||||||
evutil_closesocket(evcon->fd);
|
evutil_closesocket(evcon->fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (evcon->bind_address != NULL)
|
if (evcon->bind_address != NULL)
|
||||||
mm_free(evcon->bind_address);
|
mm_free(evcon->bind_address);
|
||||||
@ -1042,6 +1044,7 @@ evhttp_connection_reset(struct evhttp_connection *evcon)
|
|||||||
if (evhttp_connected(evcon) && evcon->closecb != NULL)
|
if (evhttp_connected(evcon) && evcon->closecb != NULL)
|
||||||
(*evcon->closecb)(evcon, evcon->closecb_arg);
|
(*evcon->closecb)(evcon, evcon->closecb_arg);
|
||||||
|
|
||||||
|
shutdown(evcon->fd, 1);
|
||||||
evutil_closesocket(evcon->fd);
|
evutil_closesocket(evcon->fd);
|
||||||
evcon->fd = -1;
|
evcon->fd = -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user