diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2018-12-28 04:42:20 +0000 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2019-01-07 15:22:39 +0300 |
commit | 28d7221b851093611c65b5961e138403dd7332b6 (patch) | |
tree | 4fdc0966836367af72c166be13b94ee134c98b8b /http.c | |
parent | 246f44041e0782f728fa5ff2d39113005a1ab02d (diff) | |
download | libevent-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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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); } |