]> 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>
Sat, 2 Feb 2019 12:18:06 +0000 (15:18 +0300)
Closes: #738 (cherry-picked)
(cherry picked from commit 28d7221b851093611c65b5961e138403dd7332b6)

http.c

diff --git a/http.c b/http.c
index 3ed3fd9b69ecb678b9763924615d1fa5609c5f5a..69071867df37c0340b0f082173a0165510b26955 100644 (file)
--- a/http.c
+++ b/http.c
@@ -3531,13 +3531,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);
        }