120Sigor@sysoev.ru 220Sigor@sysoev.ru /* 320Sigor@sysoev.ru * Copyright (C) Igor Sysoev 420Sigor@sysoev.ru * Copyright (C) Valentin V. Bartenev 520Sigor@sysoev.ru * Copyright (C) NGINX, Inc. 620Sigor@sysoev.ru */ 720Sigor@sysoev.ru 820Sigor@sysoev.ru #ifndef _NXT_RUNTIME_H_INCLUDED_ 920Sigor@sysoev.ru #define _NXT_RUNTIME_H_INCLUDED_ 1020Sigor@sysoev.ru 1120Sigor@sysoev.ru 1220Sigor@sysoev.ru typedef void (*nxt_runtime_cont_t)(nxt_task_t *task); 1320Sigor@sysoev.ru 1420Sigor@sysoev.ru 1520Sigor@sysoev.ru struct nxt_runtime_s { 1665Sigor@sysoev.ru nxt_mp_t *mem_pool; 1720Sigor@sysoev.ru 1820Sigor@sysoev.ru nxt_array_t *inherited_sockets; /* of nxt_listen_socket_t */ 1920Sigor@sysoev.ru nxt_array_t *listen_sockets; /* of nxt_listen_socket_t */ 2020Sigor@sysoev.ru 2120Sigor@sysoev.ru nxt_array_t *services; /* of nxt_service_t */ 22216Sigor@sysoev.ru nxt_array_t *languages; /* of nxt_app_lang_module_t */ 2353Sigor@sysoev.ru void *data; 2420Sigor@sysoev.ru 2520Sigor@sysoev.ru nxt_runtime_cont_t start; 2620Sigor@sysoev.ru 2720Sigor@sysoev.ru nxt_str_t hostname; 2820Sigor@sysoev.ru 2920Sigor@sysoev.ru nxt_file_name_t *pid_file; 3020Sigor@sysoev.ru 3120Sigor@sysoev.ru nxt_array_t *thread_pools; /* of nxt_thread_pool_t */ 3220Sigor@sysoev.ru nxt_runtime_cont_t continuation; 3320Sigor@sysoev.ru 3442Smax.romanov@nginx.com nxt_process_t *mprocess; 3542Smax.romanov@nginx.com size_t nprocesses; 36196Smax.romanov@nginx.com nxt_thread_mutex_t processes_mutex; 3742Smax.romanov@nginx.com nxt_lvlhsh_t processes; /* of nxt_process_t */ 3842Smax.romanov@nginx.com 39141Smax.romanov@nginx.com nxt_port_t *port_by_type[NXT_PROCESS_MAX]; 4042Smax.romanov@nginx.com nxt_lvlhsh_t ports; /* of nxt_port_t */ 4120Sigor@sysoev.ru 4220Sigor@sysoev.ru nxt_list_t *log_files; /* of nxt_file_t */ 4320Sigor@sysoev.ru 4420Sigor@sysoev.ru uint32_t last_engine_id; 4520Sigor@sysoev.ru 46*696Sigor@sysoev.ru nxt_process_type_t type; 4720Sigor@sysoev.ru 4820Sigor@sysoev.ru nxt_timer_t timer; 4920Sigor@sysoev.ru 5020Sigor@sysoev.ru uint8_t daemon; 5120Sigor@sysoev.ru uint8_t batch; 5220Sigor@sysoev.ru const char *engine; 5320Sigor@sysoev.ru uint32_t engine_connections; 5420Sigor@sysoev.ru uint32_t auxiliary_threads; 5520Sigor@sysoev.ru nxt_user_cred_t user_cred; 5620Sigor@sysoev.ru const char *group; 5720Sigor@sysoev.ru const char *pid; 58230Sigor@sysoev.ru const char *log; 59233Sigor@sysoev.ru const char *modules; 60314Svbart@nginx.com const char *state; 61314Svbart@nginx.com const char *conf; 62314Svbart@nginx.com const char *conf_tmp; 63234Sigor@sysoev.ru const char *control; 6420Sigor@sysoev.ru 6553Sigor@sysoev.ru nxt_queue_t engines; /* of nxt_event_engine_t */ 6653Sigor@sysoev.ru 6720Sigor@sysoev.ru nxt_sockaddr_t *controller_listen; 6820Sigor@sysoev.ru nxt_listen_socket_t *controller_socket; 6920Sigor@sysoev.ru nxt_str_t upstream; 7020Sigor@sysoev.ru }; 7120Sigor@sysoev.ru 7220Sigor@sysoev.ru 7320Sigor@sysoev.ru 7420Sigor@sysoev.ru typedef nxt_int_t (*nxt_module_init_t)(nxt_thread_t *thr, nxt_runtime_t *rt); 7520Sigor@sysoev.ru 7620Sigor@sysoev.ru 7720Sigor@sysoev.ru nxt_int_t nxt_runtime_create(nxt_task_t *task); 7820Sigor@sysoev.ru void nxt_runtime_quit(nxt_task_t *task); 7920Sigor@sysoev.ru 8020Sigor@sysoev.ru void nxt_runtime_event_engine_free(nxt_runtime_t *rt); 8120Sigor@sysoev.ru 8220Sigor@sysoev.ru nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt, 8320Sigor@sysoev.ru nxt_uint_t max_threads, nxt_nsec_t timeout); 8420Sigor@sysoev.ru 8520Sigor@sysoev.ru 8642Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_new(nxt_runtime_t *rt); 8742Smax.romanov@nginx.com 8842Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid); 8942Smax.romanov@nginx.com 90343Smax.romanov@nginx.com void nxt_runtime_process_add(nxt_task_t *task, nxt_process_t *process); 9142Smax.romanov@nginx.com 9242Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_find(nxt_runtime_t *rt, nxt_pid_t pid); 9342Smax.romanov@nginx.com 94349Smax.romanov@nginx.com void nxt_process_use(nxt_task_t *task, nxt_process_t *process, int i); 9542Smax.romanov@nginx.com 9642Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_first(nxt_runtime_t *rt, 9742Smax.romanov@nginx.com nxt_lvlhsh_each_t *lhe); 9842Smax.romanov@nginx.com 9942Smax.romanov@nginx.com #define nxt_runtime_process_next(rt, lhe) \ 10042Smax.romanov@nginx.com nxt_lvlhsh_each(&rt->processes, lhe) 10142Smax.romanov@nginx.com 10242Smax.romanov@nginx.com 103343Smax.romanov@nginx.com void nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port); 10442Smax.romanov@nginx.com 105343Smax.romanov@nginx.com void nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port); 10642Smax.romanov@nginx.com 10742Smax.romanov@nginx.com nxt_port_t *nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid, 10842Smax.romanov@nginx.com nxt_port_id_t port_id); 10942Smax.romanov@nginx.com 11020Sigor@sysoev.ru 11120Sigor@sysoev.ru /* STUB */ 11220Sigor@sysoev.ru nxt_int_t nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt); 11320Sigor@sysoev.ru 11465Sigor@sysoev.ru nxt_str_t *nxt_current_directory(nxt_mp_t *mp); 11520Sigor@sysoev.ru 11620Sigor@sysoev.ru nxt_listen_socket_t *nxt_runtime_listen_socket_add(nxt_runtime_t *rt, 11720Sigor@sysoev.ru nxt_sockaddr_t *sa); 11820Sigor@sysoev.ru nxt_int_t nxt_runtime_listen_sockets_create(nxt_task_t *task, 11920Sigor@sysoev.ru nxt_runtime_t *rt); 12020Sigor@sysoev.ru nxt_int_t nxt_runtime_listen_sockets_enable(nxt_task_t *task, 12120Sigor@sysoev.ru nxt_runtime_t *rt); 12220Sigor@sysoev.ru nxt_file_t *nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name); 12320Sigor@sysoev.ru 12420Sigor@sysoev.ru /* STUB */ 12520Sigor@sysoev.ru void nxt_cdecl nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log, 12620Sigor@sysoev.ru const char *fmt, ...); 12720Sigor@sysoev.ru 12820Sigor@sysoev.ru void nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data); 12920Sigor@sysoev.ru 130421Smax.romanov@nginx.com void nxt_app_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); 131421Smax.romanov@nginx.com void nxt_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); 13284Smax.romanov@nginx.com 13320Sigor@sysoev.ru 13442Smax.romanov@nginx.com #define nxt_runtime_process_each(rt, process) \ 13542Smax.romanov@nginx.com do { \ 13642Smax.romanov@nginx.com nxt_lvlhsh_each_t _lhe; \ 137125Smax.romanov@nginx.com nxt_process_t *_nxt; \ 13842Smax.romanov@nginx.com \ 13942Smax.romanov@nginx.com for (process = nxt_runtime_process_first(rt, &_lhe); \ 14042Smax.romanov@nginx.com process != NULL; \ 141125Smax.romanov@nginx.com process = _nxt) { \ 142125Smax.romanov@nginx.com \ 143125Smax.romanov@nginx.com _nxt = nxt_runtime_process_next(rt, &_lhe); \ 14442Smax.romanov@nginx.com 14542Smax.romanov@nginx.com #define nxt_runtime_process_loop \ 14642Smax.romanov@nginx.com } \ 14742Smax.romanov@nginx.com } while(0) 14842Smax.romanov@nginx.com 14942Smax.romanov@nginx.com 15020Sigor@sysoev.ru extern nxt_module_init_t nxt_init_modules[]; 15120Sigor@sysoev.ru extern nxt_uint_t nxt_init_modules_n; 15220Sigor@sysoev.ru 15320Sigor@sysoev.ru 15420Sigor@sysoev.ru #endif /* _NXT_RUNTIME_H_INCLIDED_ */ 155