summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2018-12-28 04:42:20 +0000
committerAzat Khuzhin <azat@libevent.org>2019-01-07 15:22:39 +0300
commit28d7221b851093611c65b5961e138403dd7332b6 (patch)
tree4fdc0966836367af72c166be13b94ee134c98b8b /http.c
parent246f44041e0782f728fa5ff2d39113005a1ab02d (diff)
downloadlibevent-28d7221b851093611c65b5961e138403dd7332b6.tar.gz
http: Preserve socket error from listen across closesocket cleanup
Closes: #738 (cherry-picked)
Diffstat (limited to 'http.c')
-rw-r--r--http.c3
1 files changed, 3 insertions, 0 deletions
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);
}