mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fix #1182: Fix Resource leak (socket), at startup.
git-svn-id: file:///svn/unbound/trunk@3961 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
163e7046cb
commit
235e1399eb
2 changed files with 16 additions and 4 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
13 December 2016: Wouter
|
||||||
|
- Fix #1182: Fix Resource leak (socket), at startup.
|
||||||
|
|
||||||
9 December 2016: Wouter
|
9 December 2016: Wouter
|
||||||
- Fix #1176: stack size too small for Alpine Linux.
|
- Fix #1176: stack size too small for Alpine Linux.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -720,28 +720,37 @@ create_local_accept_sock(const char *path, int* noproto)
|
||||||
/* The socket already exists and cannot be removed */
|
/* The socket already exists and cannot be removed */
|
||||||
log_err("Cannot remove old local socket %s (%s)",
|
log_err("Cannot remove old local socket %s (%s)",
|
||||||
path, strerror(errno));
|
path, strerror(errno));
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr *)&usock,
|
if (bind(s, (struct sockaddr *)&usock,
|
||||||
(socklen_t)sizeof(struct sockaddr_un)) == -1) {
|
(socklen_t)sizeof(struct sockaddr_un)) == -1) {
|
||||||
log_err("Cannot bind local socket %s (%s)",
|
log_err("Cannot bind local socket %s (%s)",
|
||||||
path, strerror(errno));
|
path, strerror(errno));
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fd_set_nonblock(s)) {
|
if (!fd_set_nonblock(s)) {
|
||||||
log_err("Cannot set non-blocking mode");
|
log_err("Cannot set non-blocking mode");
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listen(s, TCP_BACKLOG) == -1) {
|
if (listen(s, TCP_BACKLOG) == -1) {
|
||||||
log_err("can't listen: %s", strerror(errno));
|
log_err("can't listen: %s", strerror(errno));
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)noproto; /*unused*/
|
(void)noproto; /*unused*/
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
err:
|
||||||
|
#ifndef USE_WINSOCK
|
||||||
|
close(s);
|
||||||
|
#else
|
||||||
|
closesocket(s);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
(void)path;
|
(void)path;
|
||||||
log_err("Local sockets are not supported");
|
log_err("Local sockets are not supported");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue