diff options
author | Valentin Bartenev <vbart@nginx.com> | 2020-04-08 15:15:24 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2020-04-08 15:15:24 +0300 |
commit | a6d9efcee1546f67a1a2b926744f7052f3536b03 (patch) | |
tree | f024036b011047ee94687838273c131b3cbb6401 /src | |
parent | 555d595f38801685f95f140f85b20f5dcfaa49cd (diff) | |
download | unit-a6d9efcee1546f67a1a2b926744f7052f3536b03.tar.gz unit-a6d9efcee1546f67a1a2b926744f7052f3536b03.tar.bz2 |
Controller: fixed cleaning up of control socket file in some cases.
Previously, the unix domain control socket file might have been left
in the file system after a failed nxt_listen_socket_create() call.
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_listen_socket.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/nxt_listen_socket.c b/src/nxt_listen_socket.c index 63ab3de3..f433cf2b 100644 --- a/src/nxt_listen_socket.c +++ b/src/nxt_listen_socket.c @@ -48,7 +48,7 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls) s = nxt_socket_create(task, family, sa->type, 0, ls->flags); if (s == -1) { - goto socket_fail; + goto fail; } if (nxt_socket_setsockopt(task, s, SOL_SOCKET, SO_REUSEADDR, 1) != NXT_OK) { @@ -95,7 +95,7 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls) access = (S_IRUSR | S_IWUSR); if (nxt_file_set_access(name, access) != NXT_OK) { - goto fail; + goto listen_fail; } } @@ -106,7 +106,7 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls) if (listen(s, ls->backlog) != 0) { nxt_alert(task, "listen(%d, %d) failed %E", s, ls->backlog, nxt_socket_errno); - goto fail; + goto listen_fail; } ls->socket = s; @@ -114,11 +114,25 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls) return NXT_OK; -fail: +listen_fail: + +#if (NXT_HAVE_UNIX_DOMAIN) + + if (family == AF_UNIX) { + nxt_file_name_t *name; - nxt_socket_close(task, s); + name = (nxt_file_name_t *) sa->u.sockaddr_un.sun_path; -socket_fail: + (void) nxt_file_delete(name); + } + +#endif + +fail: + + if (s != -1) { + nxt_socket_close(task, s); + } thr->log = old; |