summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_main_process.c
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
committerKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
commit69235c513277c64b513447d9b92c3c03d616f577 (patch)
tree0780c92ba28d92b547c85ea0bee5e3040e14dee2 /src/nxt_main_process.c
parentb9bc222021e77bbdfb12576b3e315b962cf6b399 (diff)
parentfaf97dc06058de1c929af33a68adb34d3932b374 (diff)
downloadunit-1.30.0-1.tar.gz
unit-1.30.0-1.tar.bz2
Merged with the default branch.1.30.0-1
Diffstat (limited to '')
-rw-r--r--src/nxt_main_process.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 4c89121e..7cba08d4 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -14,6 +14,9 @@
#if (NXT_TLS)
#include <nxt_cert.h>
#endif
+#if (NXT_HAVE_NJS)
+#include <nxt_script.h>
+#endif
#include <sys/mount.h>
@@ -48,6 +51,8 @@ static void nxt_main_process_signal_handler(nxt_task_t *task, void *obj,
static void nxt_main_process_cleanup(nxt_task_t *task, nxt_process_t *process);
static void nxt_main_port_socket_handler(nxt_task_t *task,
nxt_port_recv_msg_t *msg);
+static void nxt_main_port_socket_unlink_handler(nxt_task_t *task,
+ nxt_port_recv_msg_t *msg);
static nxt_int_t nxt_main_listening_socket(nxt_sockaddr_t *sa,
nxt_listening_socket_t *ls);
static void nxt_main_port_modules_handler(nxt_task_t *task,
@@ -119,6 +124,18 @@ static nxt_conf_map_t nxt_common_app_conf[] = {
},
{
+ nxt_string("stdout"),
+ NXT_CONF_MAP_CSTRZ,
+ offsetof(nxt_common_app_conf_t, stdout_log),
+ },
+
+ {
+ nxt_string("stderr"),
+ NXT_CONF_MAP_CSTRZ,
+ offsetof(nxt_common_app_conf_t, stderr_log),
+ },
+
+ {
nxt_string("working_directory"),
NXT_CONF_MAP_CSTRZ,
offsetof(nxt_common_app_conf_t, working_directory),
@@ -587,12 +604,17 @@ static nxt_port_handlers_t nxt_main_process_port_handlers = {
.remove_pid = nxt_port_remove_pid_handler,
.start_process = nxt_main_start_process_handler,
.socket = nxt_main_port_socket_handler,
+ .socket_unlink = nxt_main_port_socket_unlink_handler,
.modules = nxt_main_port_modules_handler,
.conf_store = nxt_main_port_conf_store_handler,
#if (NXT_TLS)
.cert_get = nxt_cert_store_get_handler,
.cert_delete = nxt_cert_store_delete_handler,
#endif
+#if (NXT_HAVE_NJS)
+ .script_get = nxt_script_store_get_handler,
+ .script_delete = nxt_script_store_delete_handler,
+#endif
.access_log = nxt_main_port_access_log_handler,
.rpc_ready = nxt_port_rpc_handler,
.rpc_error = nxt_port_rpc_handler,
@@ -1182,8 +1204,9 @@ nxt_main_listening_socket(nxt_sockaddr_t *sa, nxt_listening_socket_t *ls)
if (sa->u.sockaddr.sa_family == AF_UNIX
&& sa->u.sockaddr_un.sun_path[0] != '\0')
{
- char *filename;
- mode_t access;
+ char *filename;
+ mode_t access;
+ nxt_thread_t *thr;
filename = sa->u.sockaddr_un.sun_path;
access = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
@@ -1194,6 +1217,9 @@ nxt_main_listening_socket(nxt_sockaddr_t *sa, nxt_listening_socket_t *ls)
filename, nxt_errno);
goto fail;
}
+
+ thr = nxt_thread();
+ nxt_runtime_listen_socket_add(thr->runtime, sa);
}
#endif
@@ -1210,6 +1236,49 @@ fail:
}
+static void
+nxt_main_port_socket_unlink_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
+{
+#if (NXT_HAVE_UNIX_DOMAIN)
+ size_t i;
+ nxt_buf_t *b;
+ const char *filename;
+ nxt_runtime_t *rt;
+ nxt_sockaddr_t *sa;
+ nxt_listen_socket_t *ls;
+
+ b = msg->buf;
+ sa = (nxt_sockaddr_t *) b->mem.pos;
+
+ filename = sa->u.sockaddr_un.sun_path;
+ unlink(filename);
+
+ rt = task->thread->runtime;
+
+ for (i = 0; i < rt->listen_sockets->nelts; i++) {
+ const char *name;
+
+ ls = (nxt_listen_socket_t *) rt->listen_sockets->elts + i;
+ sa = ls->sockaddr;
+
+ if (sa->u.sockaddr.sa_family != AF_UNIX
+ || sa->u.sockaddr_un.sun_path[0] == '\0')
+ {
+ continue;
+ }
+
+ name = sa->u.sockaddr_un.sun_path;
+ if (strcmp(name, filename) != 0) {
+ continue;
+ }
+
+ nxt_array_remove(rt->listen_sockets, ls);
+ break;
+ }
+#endif
+}
+
+
static nxt_conf_map_t nxt_app_lang_module_map[] = {
{
nxt_string("type"),