59 lines
1.9 KiB
Diff
59 lines
1.9 KiB
Diff
|
|
From 2385638edf9cb833ebc2759cdb6d6d45dc51a0da Mon Sep 17 00:00:00 2001
|
||
|
|
From: Azat Khuzhin <azat@libevent.org>
|
||
|
|
Date: Tue, 23 Mar 2021 09:02:39 +0300
|
||
|
|
Subject: [PATCH] http: fix fd leak on fd reset (by using
|
||
|
|
bufferevent_replacefd())
|
||
|
|
|
||
|
|
Reference:https://github.com/libevent/libevent/commit/2385638edf9cb833ebc2759cdb6d6d45dc51a0da
|
||
|
|
Conflict:NA
|
||
|
|
|
||
|
|
Fixes: afa66ea4 ("http: eliminate redundant bev fd manipulating and caching [WIP]")
|
||
|
|
---
|
||
|
|
http.c | 8 ++++----
|
||
|
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/http.c b/http.c
|
||
|
|
index 551b63b..420049a 100644
|
||
|
|
--- a/http.c
|
||
|
|
+++ b/http.c
|
||
|
|
@@ -1324,7 +1324,7 @@ evhttp_connection_reset_hard_(struct evhttp_connection *evcon)
|
||
|
|
int err;
|
||
|
|
|
||
|
|
/* XXXX This is not actually an optimal fix. Instead we ought to have
|
||
|
|
- an API for "stop connecting", or use bufferevent_setfd to turn off
|
||
|
|
+ an API for "stop connecting", or use bufferevent_replacefd to turn off
|
||
|
|
connecting. But for Libevent 2.0, this seems like a minimal change
|
||
|
|
least likely to disrupt the rest of the bufferevent and http code.
|
||
|
|
|
||
|
|
@@ -1341,7 +1341,7 @@ evhttp_connection_reset_hard_(struct evhttp_connection *evcon)
|
||
|
|
(*evcon->closecb)(evcon, evcon->closecb_arg);
|
||
|
|
|
||
|
|
/** FIXME: manipulating with fd is unwanted */
|
||
|
|
- err = bufferevent_setfd(evcon->bufev, -1);
|
||
|
|
+ err = bufferevent_replacefd(evcon->bufev, -1);
|
||
|
|
EVUTIL_ASSERT(!err && "setfd");
|
||
|
|
|
||
|
|
/* we need to clean up any buffered data */
|
||
|
|
@@ -2560,7 +2560,7 @@ evhttp_connection_connect_(struct evhttp_connection *evcon)
|
||
|
|
return (-1);
|
||
|
|
}
|
||
|
|
|
||
|
|
- if (bufferevent_setfd(evcon->bufev, fd))
|
||
|
|
+ if (bufferevent_replacefd(evcon->bufev, fd))
|
||
|
|
return (-1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -4245,7 +4245,7 @@ evhttp_get_request_connection(
|
||
|
|
evcon->flags |= EVHTTP_CON_INCOMING;
|
||
|
|
evcon->state = EVCON_READING_FIRSTLINE;
|
||
|
|
|
||
|
|
- if (bufferevent_setfd(evcon->bufev, fd))
|
||
|
|
+ if (bufferevent_replacefd(evcon->bufev, fd))
|
||
|
|
goto err;
|
||
|
|
if (bufferevent_enable(evcon->bufev, EV_READ))
|
||
|
|
goto err;
|
||
|
|
--
|
||
|
|
2.33.0
|
||
|
|
|
||
|
|
|