Lines Matching refs:task

35 static nxt_int_t nxt_main_process_port_create(nxt_task_t *task,
37 static void nxt_main_process_title(nxt_task_t *task);
38 static void nxt_main_process_sigterm_handler(nxt_task_t *task, void *obj,
40 static void nxt_main_process_sigquit_handler(nxt_task_t *task, void *obj,
42 static void nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj,
44 static void nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj,
46 static void nxt_main_process_signal_handler(nxt_task_t *task, void *obj,
48 static void nxt_main_process_cleanup(nxt_task_t *task, nxt_process_t *process);
49 static void nxt_main_port_socket_handler(nxt_task_t *task,
53 static void nxt_main_port_modules_handler(nxt_task_t *task,
56 static void nxt_main_process_whoami_handler(nxt_task_t *task,
58 static void nxt_main_port_conf_store_handler(nxt_task_t *task,
60 static nxt_int_t nxt_main_file_store(nxt_task_t *task, const char *tmp_name,
62 static void nxt_main_port_access_log_handler(nxt_task_t *task,
82 nxt_main_process_start(nxt_thread_t *thr, nxt_task_t *task, in nxt_main_process_start() argument
87 if (nxt_main_process_port_create(task, rt) != NXT_OK) { in nxt_main_process_start()
91 nxt_main_process_title(task); in nxt_main_process_start()
98 return nxt_process_init_start(task, nxt_discovery_process); in nxt_main_process_start()
320 nxt_main_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_data_handler() argument
322 nxt_debug(task, "main data: %*s", in nxt_main_data_handler()
328 nxt_main_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_new_port_handler() argument
333 nxt_port_new_port_handler(task, msg); in nxt_main_new_port_handler()
354 nxt_main_start_process_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_start_process_handler() argument
368 rt = task->thread->runtime; in nxt_main_start_process_handler()
372 nxt_alert(task, "router port not found"); in nxt_main_start_process_handler()
377 nxt_alert(task, "process %PI cannot start processes", in nxt_main_start_process_handler()
390 nxt_process_use(task, process, -1); in nxt_main_start_process_handler()
405 nxt_debug(task, "main start prototype: %*s", b->mem.free - b->mem.pos, in nxt_main_start_process_handler()
443 nxt_alert(task, "router app configuration parsing error"); in nxt_main_start_process_handler()
448 rt = task->thread->runtime; in nxt_main_start_process_handler()
457 nxt_alert(task, "failed to map common app conf received from router"); in nxt_main_start_process_handler()
472 nxt_alert(task, "invalid app type %d received from router", (int) idx); in nxt_main_start_process_handler()
480 nxt_alert(task, "failed to map app conf received from router"); in nxt_main_start_process_handler()
491 nxt_alert(task, "failed to map app limits received from router"); in nxt_main_start_process_handler()
501 ret = nxt_process_start(task, process); in nxt_main_start_process_handler()
519 nxt_process_use(task, process, -1); in nxt_main_start_process_handler()
525 nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR, in nxt_main_start_process_handler()
540 nxt_main_process_created_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_process_created_handler() argument
546 rt = task->thread->runtime; in nxt_main_process_created_handler()
561 if (nxt_slow_path(nxt_clone_credential_map(task, process->pid, in nxt_main_process_created_handler()
566 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR, in nxt_main_process_created_handler()
576 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_READY_LAST, in nxt_main_process_created_handler()
603 nxt_main_process_whoami_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_process_whoami_handler() argument
616 nxt_alert(task, "whoami: buffer is NULL or unexpected size"); in nxt_main_process_whoami_handler()
622 rt = task->thread->runtime; in nxt_main_process_whoami_handler()
626 nxt_alert(task, "whoami: parent process %PI not found", ppid); in nxt_main_process_whoami_handler()
632 nxt_debug(task, "whoami: from %PI, parent %PI, fd %d", pid, ppid, in nxt_main_process_whoami_handler()
636 port = nxt_runtime_process_port_create(task, rt, pid, 0, in nxt_main_process_whoami_handler()
642 nxt_fd_nonblocking(task, msg->fd[0]); in nxt_main_process_whoami_handler()
650 port->socket.task = task; in nxt_main_process_whoami_handler()
652 nxt_port_write_enable(task, port); in nxt_main_process_whoami_handler()
665 buf = nxt_buf_mem_alloc(task->thread->engine->mem_pool, in nxt_main_process_whoami_handler()
673 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_READY_LAST, -1, in nxt_main_process_whoami_handler()
685 nxt_main_process_port_create(nxt_task_t *task, nxt_runtime_t *rt) in nxt_main_process_port_create() argument
691 port = nxt_runtime_process_port_create(task, rt, nxt_pid, 0, in nxt_main_process_port_create()
699 ret = nxt_port_socket_init(task, port, 0); in nxt_main_process_port_create()
701 nxt_port_use(task, port, -1); in nxt_main_process_port_create()
709 nxt_port_enable(task, port, &nxt_main_process_port_handlers); in nxt_main_process_port_create()
718 nxt_main_process_title(nxt_task_t *task) in nxt_main_process_title() argument
739 nxt_process_title(task, "%s", title); in nxt_main_process_title()
744 nxt_main_process_sigterm_handler(nxt_task_t *task, void *obj, void *data) in nxt_main_process_sigterm_handler() argument
746 nxt_debug(task, "sigterm handler signo:%d (%s)", in nxt_main_process_sigterm_handler()
753 nxt_runtime_quit(task, 0); in nxt_main_process_sigterm_handler()
758 nxt_main_process_sigquit_handler(nxt_task_t *task, void *obj, void *data) in nxt_main_process_sigquit_handler() argument
760 nxt_debug(task, "sigquit handler signo:%d (%s)", in nxt_main_process_sigquit_handler()
767 nxt_runtime_quit(task, 0); in nxt_main_process_sigquit_handler()
772 nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj, void *data) in nxt_main_process_sigusr1_handler() argument
782 nxt_log(task, NXT_LOG_NOTICE, "signal %d (%s) recevied, %s", in nxt_main_process_sigusr1_handler()
785 rt = task->thread->runtime; in nxt_main_process_sigusr1_handler()
790 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_ACCESS_LOG, in nxt_main_process_sigusr1_handler()
816 ret = nxt_file_open(task, new_file, O_WRONLY | O_APPEND, O_CREAT, in nxt_main_process_sigusr1_handler()
834 nxt_port_change_log_file(task, rt, n, new_file[n].fd); in nxt_main_process_sigusr1_handler()
858 nxt_file_close(task, new_file); in nxt_main_process_sigusr1_handler()
870 nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj, void *data) in nxt_main_process_sigchld_handler() argument
882 nxt_debug(task, "sigchld handler signo:%d (%s)", in nxt_main_process_sigchld_handler()
885 rt = task->thread->runtime; in nxt_main_process_sigchld_handler()
901 nxt_alert(task, "waitpid() failed: %E", err); in nxt_main_process_sigchld_handler()
906 nxt_debug(task, "waitpid(): %PI", pid); in nxt_main_process_sigchld_handler()
914 nxt_alert(task, "process %PI exited on signal %d%s", in nxt_main_process_sigchld_handler()
918 nxt_alert(task, "process %PI exited on signal %d", in nxt_main_process_sigchld_handler()
923 nxt_trace(task, "process %PI exited with code %d", in nxt_main_process_sigchld_handler()
930 nxt_main_process_cleanup(task, process); in nxt_main_process_sigchld_handler()
946 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, in nxt_main_process_sigchld_handler()
952 nxt_process_close_ports(task, process); in nxt_main_process_sigchld_handler()
958 nxt_process_close_ports(task, child); in nxt_main_process_sigchld_handler()
962 nxt_runtime_quit(task, 0); in nxt_main_process_sigchld_handler()
970 nxt_port_remove_notify_others(task, process); in nxt_main_process_sigchld_handler()
973 nxt_port_remove_notify_others(task, child); in nxt_main_process_sigchld_handler()
978 nxt_process_close_ports(task, child); in nxt_main_process_sigchld_handler()
983 nxt_process_close_ports(task, process); in nxt_main_process_sigchld_handler()
986 ret = nxt_process_init_start(task, init); in nxt_main_process_sigchld_handler()
988 nxt_alert(task, "failed to restart %s", init.name); in nxt_main_process_sigchld_handler()
997 nxt_main_process_signal_handler(nxt_task_t *task, void *obj, void *data) in nxt_main_process_signal_handler() argument
999 nxt_trace(task, "signal signo:%d (%s) recevied, ignored", in nxt_main_process_signal_handler()
1005 nxt_main_process_cleanup(nxt_task_t *task, nxt_process_t *process) in nxt_main_process_cleanup() argument
1008 process->isolation.cleanup(task, process); in nxt_main_process_cleanup()
1014 nxt_main_port_socket_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_port_socket_handler() argument
1025 port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid, in nxt_main_port_socket_handler()
1032 nxt_alert(task, "process %PI cannot create listener sockets", in nxt_main_port_socket_handler()
1048 nxt_debug(task, "listening socket \"%*s\"", in nxt_main_port_socket_handler()
1054 nxt_debug(task, "socket(\"%*s\"): %d", in nxt_main_port_socket_handler()
1064 nxt_alert(task, "%*s", size, ls.start); in nxt_main_port_socket_handler()
1066 out = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool, in nxt_main_port_socket_handler()
1077 nxt_port_socket_write(task, port, type, ls.socket, msg->port_msg.stream, in nxt_main_port_socket_handler()
1265 nxt_main_port_modules_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_port_modules_handler() argument
1280 rt = task->thread->runtime; in nxt_main_port_modules_handler()
1283 nxt_alert(task, "process %PI cannot send modules", msg->port_msg.pid); in nxt_main_port_modules_handler()
1288 nxt_debug(task, "ignoring discovered modules, exiting"); in nxt_main_port_modules_handler()
1292 port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid, in nxt_main_port_modules_handler()
1296 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR, -1, in nxt_main_port_modules_handler()
1317 nxt_debug(task, "application languages: \"%*s\"", in nxt_main_port_modules_handler()
1352 nxt_alert(task, "missing mounts from discovery message."); in nxt_main_port_modules_handler()
1357 nxt_alert(task, "invalid mounts type from discovery message."); in nxt_main_port_modules_handler()
1393 nxt_debug(task, "lang %d %s \"%s\" (%d mounts)", in nxt_main_port_modules_handler()
1404 ret = nxt_process_init_start(task, nxt_controller_process); in nxt_main_port_modules_handler()
1406 ret = nxt_process_init_start(task, nxt_router_process); in nxt_main_port_modules_handler()
1412 nxt_runtime_quit(task, 1); in nxt_main_port_modules_handler()
1441 nxt_main_port_conf_store_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_port_conf_store_handler() argument
1450 rt = task->thread->runtime; in nxt_main_port_conf_store_handler()
1455 nxt_alert(task, "process %PI cannot store conf", msg->port_msg.pid); in nxt_main_port_conf_store_handler()
1468 nxt_alert(task, "conf_store_handler: invalid shm fd"); in nxt_main_port_conf_store_handler()
1473 nxt_alert(task, "conf_store_handler: unexpected buffer size (%d)", in nxt_main_port_conf_store_handler()
1489 nxt_debug(task, "conf_store_handler(%uz): %*s", size, size, p); in nxt_main_port_conf_store_handler()
1494 ret = nxt_main_file_store(task, rt->ver_tmp, rt->ver, ver, n); in nxt_main_port_conf_store_handler()
1502 ret = nxt_main_file_store(task, rt->conf_tmp, rt->conf, p, size); in nxt_main_port_conf_store_handler()
1510 nxt_alert(task, "failed to store current configuration"); in nxt_main_port_conf_store_handler()
1526 nxt_main_file_store(nxt_task_t *task, const char *tmp_name, const char *name, in nxt_main_file_store() argument
1537 ret = nxt_file_open(task, &file, NXT_FILE_WRONLY, NXT_FILE_TRUNCATE, in nxt_main_file_store()
1545 nxt_file_close(task, &file); in nxt_main_file_store()
1557 nxt_main_port_access_log_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_main_port_access_log_handler() argument
1565 nxt_debug(task, "opening access log file"); in nxt_main_port_access_log_handler()
1574 ret = nxt_file_open(task, &file, O_WRONLY | O_APPEND, O_CREAT, in nxt_main_port_access_log_handler()
1580 port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid, in nxt_main_port_access_log_handler()
1584 (void) nxt_port_socket_write(task, port, type, file.fd, in nxt_main_port_access_log_handler()