From 28d7221b851093611c65b5961e138403dd7332b6 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 28 Dec 2018 04:42:20 +0000 Subject: [PATCH] http: Preserve socket error from listen across closesocket cleanup Closes: #738 (cherry-picked) --- http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/http.c b/http.c index 3f2f40f4..17d45804 100644 --- 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); } -- 2.40.0