Close listenfd upon errors
This commit is contained in:
parent
c8c9abc669
commit
cd834de190
@ -195,6 +195,8 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
|
|||||||
|
|
||||||
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
|
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
|
||||||
break; /* success */
|
break; /* success */
|
||||||
|
|
||||||
|
close (listenfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rp == NULL) {
|
if (rp == NULL) {
|
||||||
@ -214,6 +216,7 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
|
|||||||
"Unable to start listening socket because of %s",
|
"Unable to start listening socket because of %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
|
|
||||||
|
close (listenfd);
|
||||||
freeaddrinfo (result);
|
freeaddrinfo (result);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user