summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_runtime.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2020-04-08 15:15:24 +0300
committerValentin Bartenev <vbart@nginx.com>2020-04-08 15:15:24 +0300
commitc7f5c1c6641838006088524c2122eae8f9c30431 (patch)
treead351deef843acb84ebbf70fea9862d43edf1168 /src/nxt_runtime.c
parenta6d9efcee1546f67a1a2b926744f7052f3536b03 (diff)
downloadunit-c7f5c1c6641838006088524c2122eae8f9c30431.tar.gz
unit-c7f5c1c6641838006088524c2122eae8f9c30431.tar.bz2
Controller: improved handling of unix domain control socket.
One of the ways to detect Unit's startup and subsequent readiness to accept commands relies on waiting for the control socket file to be created. Earlier, it was unreliable due to a race condition between the client's connect() and the daemon's listen() calls after the socket's bind() call. Now, unix domain listening sockets are created with a nxt_listen_socket_create() call as follows: s = socket(); unlink("path/to/socket.tmp") bind(s, "path/to/socket.tmp"); listen(s); rename("path/to/socket.tmp", "path/to/socket"); This eliminates a time-lapse when the socket file is already created but nobody is listening on it yet, which therefore prevents the condition described above. Also, it allows reliably detecting whether the socket is being used or simply wasn't cleaned after the daemon stopped abruptly. A successful connection to the socket file means the daemon has been started; otherwise, the file can be overwritten.
Diffstat (limited to 'src/nxt_runtime.c')
-rw-r--r--src/nxt_runtime.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index 09fad1de..bcd156ee 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -1205,7 +1205,7 @@ nxt_runtime_listen_sockets_create(nxt_task_t *task, nxt_runtime_t *rt)
}
}
- if (nxt_listen_socket_create(task, &curr[c]) != NXT_OK) {
+ if (nxt_listen_socket_create(task, rt->mem_pool, &curr[c]) != NXT_OK) {
return NXT_ERROR;
}