http: Preserve socket error from listen across closesocket cleanup

Closes: #738 (cherry-picked)
This commit is contained in:
Luke Dashjr 2018-12-28 04:42:20 +00:00 committed by Azat Khuzhin
parent 246f44041e
commit 28d7221b85
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

3
http.c
View File

@ -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);
}