Lines Matching refs:task

41 static nxt_int_t nxt_discovery_start(nxt_task_t *task,
43 static nxt_buf_t *nxt_discovery_modules(nxt_task_t *task, const char *path);
44 static nxt_int_t nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp,
46 static void nxt_discovery_completion_handler(nxt_task_t *task, void *obj,
48 static void nxt_discovery_quit(nxt_task_t *task, nxt_port_recv_msg_t *msg,
50 static nxt_app_module_t *nxt_app_module_load(nxt_task_t *task,
52 static nxt_int_t nxt_proto_setup(nxt_task_t *task, nxt_process_t *process);
53 static nxt_int_t nxt_proto_start(nxt_task_t *task, nxt_process_data_t *data);
54 static nxt_int_t nxt_app_setup(nxt_task_t *task, nxt_process_t *process);
56 static void nxt_proto_start_process_handler(nxt_task_t *task,
58 static void nxt_proto_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
59 static void nxt_proto_process_created_handler(nxt_task_t *task,
61 static void nxt_proto_quit_children(nxt_task_t *task);
62 static nxt_process_t *nxt_proto_process_find(nxt_task_t *task, nxt_pid_t pid);
63 static void nxt_proto_process_add(nxt_task_t *task, nxt_process_t *process);
64 static nxt_process_t *nxt_proto_process_remove(nxt_task_t *task, nxt_pid_t pid);
66 static void nxt_proto_signal_handler(nxt_task_t *task, void *obj, void *data);
67 static void nxt_proto_sigterm_handler(nxt_task_t *task, void *obj, void *data);
68 static void nxt_proto_sigchld_handler(nxt_task_t *task, void *obj, void *data);
164 nxt_discovery_start(nxt_task_t *task, nxt_process_data_t *data) in nxt_discovery_start() argument
172 nxt_log(task, NXT_LOG_INFO, "discovery started"); in nxt_discovery_start()
174 rt = task->thread->runtime; in nxt_discovery_start()
176 b = nxt_discovery_modules(task, rt->modules); in nxt_discovery_start()
184 stream = nxt_port_rpc_register_handler(task, discovery_port, in nxt_discovery_start()
193 ret = nxt_port_socket_write(task, main_port, NXT_PORT_MSG_MODULES, -1, in nxt_discovery_start()
197 nxt_port_rpc_cancel(task, discovery_port, stream); in nxt_discovery_start()
206 nxt_discovery_modules(nxt_task_t *task, const char *path) in nxt_discovery_modules() argument
232 nxt_log(task, NXT_LOG_NOTICE, in nxt_discovery_modules()
245 ret = nxt_discovery_module(task, mp, modules, name); in nxt_discovery_modules()
256 nxt_debug(task, "module: %d %V %V", in nxt_discovery_modules()
320 nxt_alert(task, "discovery write past the buffer"); in nxt_discovery_modules()
335 nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules, in nxt_discovery_module() argument
358 nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror()); in nxt_discovery_module()
365 nxt_log(task, NXT_LOG_NOTICE, "module: %V %s \"%s\"", in nxt_discovery_module()
371 nxt_log(task, NXT_LOG_NOTICE, "incompatible module %s", name); in nxt_discovery_module()
379 nxt_log(task, NXT_LOG_NOTICE, "unknown module type %V", &app->type); in nxt_discovery_module()
394 nxt_log(task, NXT_LOG_NOTICE, in nxt_discovery_module()
468 nxt_alert(task, "dlsym(\"%s\"), failed: \"%s\"", name, dlerror()); in nxt_discovery_module()
478 nxt_alert(task, "dlclose(\"%s\"), failed: \"%s\"", name, dlerror()); in nxt_discovery_module()
486 nxt_discovery_completion_handler(nxt_task_t *task, void *obj, void *data) in nxt_discovery_completion_handler() argument
499 nxt_discovery_quit(nxt_task_t *task, nxt_port_recv_msg_t *msg, void *data) in nxt_discovery_quit() argument
501 nxt_signal_quit_handler(task, msg); in nxt_discovery_quit()
506 nxt_proto_setup(nxt_task_t *task, nxt_process_t *process) in nxt_proto_setup() argument
518 lang = nxt_app_lang_module(task->thread->runtime, &app_conf->type); in nxt_proto_setup()
520 nxt_alert(task, "unknown application type: \"%V\"", &app_conf->type); in nxt_proto_setup()
527 nxt_debug(task, "application language module: %s \"%s\"", in nxt_proto_setup()
530 nxt_app = nxt_app_module_load(task, lang->file); in nxt_proto_setup()
539 nxt_alert(task, "failed to set environment"); in nxt_proto_setup()
544 ret = nxt_app->setup(task, process, app_conf); in nxt_proto_setup()
553 ret = nxt_isolation_prepare_rootfs(task, process); in nxt_proto_setup()
559 ret = nxt_isolation_change_root(task, process); in nxt_proto_setup()
572 nxt_log(task, NXT_LOG_WARN, "chdir(%s) failed %E", in nxt_proto_setup()
586 nxt_proto_start(nxt_task_t *task, nxt_process_data_t *data) in nxt_proto_start() argument
588 nxt_debug(task, "prototype waiting for clone messages"); in nxt_proto_start()
595 nxt_proto_start_process_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_proto_start_process_handler() argument
604 rt = task->thread->runtime; in nxt_proto_start_process_handler()
613 nxt_process_use(task, process, -1); in nxt_proto_start_process_handler()
626 nxt_process_use(task, process, -1); in nxt_proto_start_process_handler()
648 ret = nxt_process_start(task, process); in nxt_proto_start_process_handler()
650 nxt_process_use(task, process, -1); in nxt_proto_start_process_handler()
655 nxt_proto_process_add(task, process); in nxt_proto_start_process_handler()
665 nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR, in nxt_proto_start_process_handler()
672 nxt_proto_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_proto_quit_handler() argument
674 nxt_debug(task, "prototype quit handler"); in nxt_proto_quit_handler()
676 nxt_proto_quit_children(task); in nxt_proto_quit_handler()
681 nxt_process_quit(task, 0); in nxt_proto_quit_handler()
687 nxt_proto_quit_children(nxt_task_t *task) in nxt_proto_quit_children() argument
695 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, in nxt_proto_quit_children()
703 nxt_proto_process_created_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) in nxt_proto_process_created_handler() argument
710 process = nxt_proto_process_find(task, isolated_pid); in nxt_proto_process_created_handler()
720 nxt_debug(task, "app process %PI (aka %PI) is created", isolated_pid, in nxt_proto_process_created_handler()
726 nxt_debug(task, "app process %PI is created", isolated_pid); in nxt_proto_process_created_handler()
732 nxt_runtime_process_add(task, process); in nxt_proto_process_created_handler()
734 nxt_port_use(task, nxt_process_port_first(process), -1); in nxt_proto_process_created_handler()
740 nxt_proto_signal_handler(nxt_task_t *task, void *obj, void *data) in nxt_proto_signal_handler() argument
742 nxt_trace(task, "signal signo:%d (%s) received, ignored", in nxt_proto_signal_handler()
748 nxt_proto_sigterm_handler(nxt_task_t *task, void *obj, void *data) in nxt_proto_sigterm_handler() argument
750 nxt_trace(task, "signal signo:%d (%s) received", in nxt_proto_sigterm_handler()
753 nxt_proto_quit_children(task); in nxt_proto_sigterm_handler()
758 nxt_process_quit(task, 0); in nxt_proto_sigterm_handler()
764 nxt_proto_sigchld_handler(nxt_task_t *task, void *obj, void *data) in nxt_proto_sigchld_handler() argument
773 rt = task->thread->runtime; in nxt_proto_sigchld_handler()
775 nxt_debug(task, "proto sigchld handler signo:%d (%s)", in nxt_proto_sigchld_handler()
792 nxt_alert(task, "waitpid() failed: %E", err); in nxt_proto_sigchld_handler()
797 nxt_debug(task, "waitpid(): %PI", pid); in nxt_proto_sigchld_handler()
803 process = nxt_proto_process_remove(task, pid); in nxt_proto_sigchld_handler()
807 nxt_alert(task, "app process %PI (isolated %PI) " in nxt_proto_sigchld_handler()
814 nxt_alert(task, "app process %PI exited on signal %d%s", in nxt_proto_sigchld_handler()
821 nxt_trace(task, "app process %PI (isolated %PI) " in nxt_proto_sigchld_handler()
827 nxt_trace(task, "app process %PI exited with code %d", in nxt_proto_sigchld_handler()
846 nxt_port_remove_notify_others(task, process); in nxt_proto_sigchld_handler()
849 nxt_process_close_ports(task, process); in nxt_proto_sigchld_handler()
852 nxt_port_use(task, port, -1); in nxt_proto_sigchld_handler()
856 nxt_process_quit(task, 0); in nxt_proto_sigchld_handler()
864 nxt_app_module_load(nxt_task_t *task, const char *name) in nxt_app_module_load() argument
874 nxt_alert(task, "dlopen(\"%s\") failed: \"%s\"", in nxt_app_module_load()
883 nxt_alert(task, "dlsym(\"%s\", \"nxt_app_module\") failed: \"%s\"", in nxt_app_module_load()
888 nxt_alert(task, "dlclose(\"%s\") failed: \"%s\"", in nxt_app_module_load()
959 nxt_app_setup(nxt_task_t *task, nxt_process_t *process) in nxt_app_setup() argument
967 return init->start(task, &process->data); in nxt_app_setup()
1056 nxt_unit_default_init(nxt_task_t *task, nxt_unit_init_t *init, in nxt_unit_default_init() argument
1064 rt = task->thread->runtime; in nxt_unit_default_init()
1146 nxt_proto_process_add(nxt_task_t *task, nxt_process_t *process) in nxt_proto_process_add() argument
1151 rt = task->thread->runtime; in nxt_proto_process_add()
1162 nxt_debug(task, "process (isolated %PI) added", process->isolated_pid); in nxt_proto_process_add()
1168 nxt_alert(task, "process (isolated %PI) failed to add", in nxt_proto_process_add()
1176 nxt_proto_process_remove(nxt_task_t *task, nxt_pid_t pid) in nxt_proto_process_remove() argument
1184 rt = task->thread->runtime; in nxt_proto_process_remove()
1191 nxt_debug(task, "process (isolated %PI) removed", pid); in nxt_proto_process_remove()
1201 nxt_debug(task, "process (isolated %PI) remove failed", pid); in nxt_proto_process_remove()
1211 nxt_proto_process_find(nxt_task_t *task, nxt_pid_t pid) in nxt_proto_process_find() argument
1222 nxt_debug(task, "process (isolated %PI) not found", pid); in nxt_proto_process_find()