mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 12:28:19 -04:00
Fix a double close() bug in evhttp when the underlying bufferevent uses BEV_OPT_CLOSE_ON_FREE.
This commit is contained in:
parent
1f29b18f51
commit
31db8a02bd
@ -367,6 +367,8 @@ void bufferevent_init_generic_timeout_cbs_(struct bufferevent *bev);
|
||||
* that enabled EV_READ or EV_WRITE, or that disables EV_READ or EV_WRITE. */
|
||||
int bufferevent_generic_adj_timeouts_(struct bufferevent *bev);
|
||||
|
||||
enum bufferevent_options bufferevent_get_options_(struct bufferevent *bev);
|
||||
|
||||
/** Internal use: We have just successfully read data into an inbuf, so
|
||||
* reset the read timeout (if any). */
|
||||
#define BEV_RESET_GENERIC_READ_TIMEOUT(bev) \
|
||||
|
@ -820,6 +820,18 @@ bufferevent_getfd(struct bufferevent *bev)
|
||||
return (res<0) ? -1 : d.fd;
|
||||
}
|
||||
|
||||
enum bufferevent_options
|
||||
bufferevent_get_options_(struct bufferevent *bev)
|
||||
{
|
||||
struct bufferevent_private *bev_p =
|
||||
EVUTIL_UPCAST(bev, struct bufferevent_private, bev);
|
||||
|
||||
BEV_LOCK(bev);
|
||||
return bev_p->options;
|
||||
BEV_UNLOCK(bev);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bufferevent_cancel_all_(struct bufferevent *bev)
|
||||
{
|
||||
|
2
http.c
2
http.c
@ -1155,8 +1155,10 @@ evhttp_connection_free(struct evhttp_connection *evcon)
|
||||
|
||||
if (evcon->fd != -1) {
|
||||
shutdown(evcon->fd, EVUTIL_SHUT_WR);
|
||||
if (!(bufferevent_get_options_(evcon->bufev) & BEV_OPT_CLOSE_ON_FREE)) {
|
||||
evutil_closesocket(evcon->fd);
|
||||
}
|
||||
}
|
||||
|
||||
if (evcon->bind_address != NULL)
|
||||
mm_free(evcon->bind_address);
|
||||
|
Loading…
x
Reference in New Issue
Block a user