httpserver: Only make a single bind_socket_ai call from my_bind_socket_with_handle

This commit is contained in:
Luke Dashjr 2018-12-28 05:39:20 +00:00
parent a0427096a2
commit a6109d5931

View File

@ -363,9 +363,9 @@ my_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t
struct evutil_addrinfo *aitop = NULL;
/* just create an unbound socket */
int reuse;
if (address == NULL && port == 0) {
fd = bind_socket_ai(NULL, 0);
reuse = 0;
} else {
struct evutil_addrinfo hints;
char strport[NI_MAXSERV];
@ -391,10 +391,10 @@ my_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t
return nullptr;
}
fd = bind_socket_ai(aitop, 1 /*reuse*/);
evutil_freeaddrinfo(aitop);
reuse = 1;
}
fd = bind_socket_ai(aitop, reuse);
if (aitop) evutil_freeaddrinfo(aitop);
if (fd == -1)
return (NULL);