]> granicus.if.org Git - libevent/commitdiff
http: get fd from be layer during connection reset
authorAzat Khuzhin <a3at.mail@gmail.com>
Tue, 22 Mar 2016 16:29:50 +0000 (19:29 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Wed, 23 Mar 2016 09:53:03 +0000 (12:53 +0300)
Since it can be non -1, and we must close it, otherwise we will have problems.

And after this patch the following tests report fd 2307 instead of 2309 fd leaks:
$ valgrind --leak-check=full --show-reachable=yes --track-fds=yes --error-exitcode=1 regress --no-fork http/cancel..
==10853== FILE DESCRIPTORS: 2307 open at exit.

http.c

diff --git a/http.c b/http.c
index cce68ce63e05c3b59fd0d77ddbe588a15810df19..d95cf1df846345cd550b917bd51dcdd05bab467e 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1329,6 +1329,9 @@ evhttp_connection_reset_(struct evhttp_connection *evcon)
        */
        bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE);
 
+       if (evcon->fd == -1)
+               evcon->fd = bufferevent_getfd(evcon->bufev);
+
        if (evcon->fd != -1) {
                /* inform interested parties about connection close */
                if (evhttp_connected(evcon) && evcon->closecb != NULL)