]> granicus.if.org Git - libevent/commitdiff
http: Preserve socket error from listen across closesocket cleanup
authorLuke Dashjr <luke-jr+git@utopios.org>
Fri, 28 Dec 2018 04:42:20 +0000 (04:42 +0000)
committerAzat Khuzhin <azat@libevent.org>
Mon, 7 Jan 2019 12:22:39 +0000 (15:22 +0300)
Closes: #738 (cherry-picked)
http.c

diff --git a/http.c b/http.c
index 3f2f40f46babca6f238bdecc0a9df9bacd0017f5..17d4580435c7fa420c87e8391f5c567c09340a3f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -3544,13 +3544,16 @@ evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint
 {
        evutil_socket_t fd;
        struct evhttp_bound_socket *bound;
+       int serrno;
 
        if ((fd = bind_socket(address, port, 1 /*reuse*/)) == -1)
                return (NULL);
 
        if (listen(fd, 128) == -1) {
+               serrno = EVUTIL_SOCKET_ERROR();
                event_sock_warn(fd, "%s: listen", __func__);
                evutil_closesocket(fd);
+               EVUTIL_SET_SOCKET_ERROR(serrno);
                return (NULL);
        }