111Sigor@sysoev.ru
211Sigor@sysoev.ru /*
311Sigor@sysoev.ru * Copyright (C) Igor Sysoev
411Sigor@sysoev.ru * Copyright (C) NGINX, Inc.
511Sigor@sysoev.ru */
611Sigor@sysoev.ru
711Sigor@sysoev.ru #ifndef _NXT_PORT_H_INCLUDED_
811Sigor@sysoev.ru #define _NXT_PORT_H_INCLUDED_
911Sigor@sysoev.ru
1011Sigor@sysoev.ru
11320Smax.romanov@nginx.com struct nxt_port_handlers_s {
12320Smax.romanov@nginx.com /* RPC responses. */
13320Smax.romanov@nginx.com nxt_port_handler_t rpc_ready;
14320Smax.romanov@nginx.com nxt_port_handler_t rpc_error;
15320Smax.romanov@nginx.com
16320Smax.romanov@nginx.com /* Main process RPC requests. */
171488St.nateldemoura@f5.com nxt_port_handler_t start_process;
18320Smax.romanov@nginx.com nxt_port_handler_t socket;
192377Sa.clayton@nginx.com nxt_port_handler_t socket_unlink;
20320Smax.romanov@nginx.com nxt_port_handler_t modules;
21320Smax.romanov@nginx.com nxt_port_handler_t conf_store;
22774Svbart@nginx.com nxt_port_handler_t cert_get;
23774Svbart@nginx.com nxt_port_handler_t cert_delete;
24*2450Sz.hong@f5.com nxt_port_handler_t script_get;
25*2450Sz.hong@f5.com nxt_port_handler_t script_delete;
26630Svbart@nginx.com nxt_port_handler_t access_log;
27320Smax.romanov@nginx.com
28320Smax.romanov@nginx.com /* File descriptor exchange. */
29320Smax.romanov@nginx.com nxt_port_handler_t change_file;
30320Smax.romanov@nginx.com nxt_port_handler_t new_port;
311545Smax.romanov@nginx.com nxt_port_handler_t get_port;
321666Smax.romanov@nginx.com nxt_port_handler_t port_ack;
33320Smax.romanov@nginx.com nxt_port_handler_t mmap;
341546Smax.romanov@nginx.com nxt_port_handler_t get_mmap;
35320Smax.romanov@nginx.com
361488St.nateldemoura@f5.com /* New process */
371488St.nateldemoura@f5.com nxt_port_handler_t process_created;
38320Smax.romanov@nginx.com nxt_port_handler_t process_ready;
391998St.nateldemoura@f5.com nxt_port_handler_t whoami;
40320Smax.romanov@nginx.com
41320Smax.romanov@nginx.com /* Process exit/crash notification. */
42320Smax.romanov@nginx.com nxt_port_handler_t remove_pid;
43320Smax.romanov@nginx.com
44320Smax.romanov@nginx.com /* Stop process command. */
45320Smax.romanov@nginx.com nxt_port_handler_t quit;
46320Smax.romanov@nginx.com
471131Smax.romanov@nginx.com /* Request headers. */
481131Smax.romanov@nginx.com nxt_port_handler_t req_headers;
491547Smax.romanov@nginx.com nxt_port_handler_t req_headers_ack;
501555Smax.romanov@nginx.com nxt_port_handler_t req_body;
511131Smax.romanov@nginx.com
521131Smax.romanov@nginx.com /* Websocket frame. */
531131Smax.romanov@nginx.com nxt_port_handler_t websocket_frame;
541131Smax.romanov@nginx.com
55320Smax.romanov@nginx.com /* Various data. */
56320Smax.romanov@nginx.com nxt_port_handler_t data;
571926Smax.romanov@nginx.com nxt_port_handler_t app_restart;
581321Smax.romanov@nginx.com
592185Svbart@nginx.com /* Status report. */
602185Svbart@nginx.com nxt_port_handler_t status;
612185Svbart@nginx.com
621321Smax.romanov@nginx.com nxt_port_handler_t oosm;
631321Smax.romanov@nginx.com nxt_port_handler_t shm_ack;
641555Smax.romanov@nginx.com nxt_port_handler_t read_queue;
651555Smax.romanov@nginx.com nxt_port_handler_t read_socket;
66320Smax.romanov@nginx.com };
67320Smax.romanov@nginx.com
68320Smax.romanov@nginx.com
69320Smax.romanov@nginx.com #define nxt_port_handler_idx(name) \
70389Smax.romanov@nginx.com ( offsetof(nxt_port_handlers_t, name) / sizeof(nxt_port_handler_t) )
71320Smax.romanov@nginx.com
721488St.nateldemoura@f5.com #define nxt_msg_last(handler) \
731488St.nateldemoura@f5.com (handler | NXT_PORT_MSG_LAST)
74320Smax.romanov@nginx.com
7542Smax.romanov@nginx.com typedef enum {
761488St.nateldemoura@f5.com NXT_PORT_MSG_LAST = 0x100,
771488St.nateldemoura@f5.com NXT_PORT_MSG_CLOSE_FD = 0x200,
781488St.nateldemoura@f5.com NXT_PORT_MSG_SYNC = 0x400,
79189Smax.romanov@nginx.com
801488St.nateldemoura@f5.com NXT_PORT_MSG_MASK = 0xFF,
81189Smax.romanov@nginx.com
821488St.nateldemoura@f5.com _NXT_PORT_MSG_RPC_READY = nxt_port_handler_idx(rpc_ready),
831488St.nateldemoura@f5.com _NXT_PORT_MSG_RPC_ERROR = nxt_port_handler_idx(rpc_error),
84320Smax.romanov@nginx.com
851488St.nateldemoura@f5.com _NXT_PORT_MSG_START_PROCESS = nxt_port_handler_idx(start_process),
861488St.nateldemoura@f5.com _NXT_PORT_MSG_SOCKET = nxt_port_handler_idx(socket),
872377Sa.clayton@nginx.com _NXT_PORT_MSG_SOCKET_UNLINK = nxt_port_handler_idx(socket_unlink),
881488St.nateldemoura@f5.com _NXT_PORT_MSG_MODULES = nxt_port_handler_idx(modules),
891488St.nateldemoura@f5.com _NXT_PORT_MSG_CONF_STORE = nxt_port_handler_idx(conf_store),
901488St.nateldemoura@f5.com _NXT_PORT_MSG_CERT_GET = nxt_port_handler_idx(cert_get),
911488St.nateldemoura@f5.com _NXT_PORT_MSG_CERT_DELETE = nxt_port_handler_idx(cert_delete),
92*2450Sz.hong@f5.com _NXT_PORT_MSG_SCRIPT_GET = nxt_port_handler_idx(script_get),
93*2450Sz.hong@f5.com _NXT_PORT_MSG_SCRIPT_DELETE = nxt_port_handler_idx(script_delete),
941488St.nateldemoura@f5.com _NXT_PORT_MSG_ACCESS_LOG = nxt_port_handler_idx(access_log),
9542Smax.romanov@nginx.com
961488St.nateldemoura@f5.com _NXT_PORT_MSG_CHANGE_FILE = nxt_port_handler_idx(change_file),
971488St.nateldemoura@f5.com _NXT_PORT_MSG_NEW_PORT = nxt_port_handler_idx(new_port),
981545Smax.romanov@nginx.com _NXT_PORT_MSG_GET_PORT = nxt_port_handler_idx(get_port),
991666Smax.romanov@nginx.com _NXT_PORT_MSG_PORT_ACK = nxt_port_handler_idx(port_ack),
1001488St.nateldemoura@f5.com _NXT_PORT_MSG_MMAP = nxt_port_handler_idx(mmap),
1011546Smax.romanov@nginx.com _NXT_PORT_MSG_GET_MMAP = nxt_port_handler_idx(get_mmap),
102320Smax.romanov@nginx.com
1031488St.nateldemoura@f5.com _NXT_PORT_MSG_PROCESS_CREATED = nxt_port_handler_idx(process_created),
1041488St.nateldemoura@f5.com _NXT_PORT_MSG_PROCESS_READY = nxt_port_handler_idx(process_ready),
1051998St.nateldemoura@f5.com _NXT_PORT_MSG_WHOAMI = nxt_port_handler_idx(whoami),
1061488St.nateldemoura@f5.com _NXT_PORT_MSG_REMOVE_PID = nxt_port_handler_idx(remove_pid),
1071488St.nateldemoura@f5.com _NXT_PORT_MSG_QUIT = nxt_port_handler_idx(quit),
1081131Smax.romanov@nginx.com
1091488St.nateldemoura@f5.com _NXT_PORT_MSG_REQ_HEADERS = nxt_port_handler_idx(req_headers),
1101547Smax.romanov@nginx.com _NXT_PORT_MSG_REQ_HEADERS_ACK = nxt_port_handler_idx(req_headers_ack),
1111555Smax.romanov@nginx.com _NXT_PORT_MSG_REQ_BODY = nxt_port_handler_idx(req_body),
1121488St.nateldemoura@f5.com _NXT_PORT_MSG_WEBSOCKET = nxt_port_handler_idx(websocket_frame),
113189Smax.romanov@nginx.com
1141488St.nateldemoura@f5.com _NXT_PORT_MSG_DATA = nxt_port_handler_idx(data),
1151926Smax.romanov@nginx.com _NXT_PORT_MSG_APP_RESTART = nxt_port_handler_idx(app_restart),
1162185Svbart@nginx.com _NXT_PORT_MSG_STATUS = nxt_port_handler_idx(status),
1171321Smax.romanov@nginx.com
1181488St.nateldemoura@f5.com _NXT_PORT_MSG_OOSM = nxt_port_handler_idx(oosm),
1191488St.nateldemoura@f5.com _NXT_PORT_MSG_SHM_ACK = nxt_port_handler_idx(shm_ack),
1201555Smax.romanov@nginx.com _NXT_PORT_MSG_READ_QUEUE = nxt_port_handler_idx(read_queue),
1211555Smax.romanov@nginx.com _NXT_PORT_MSG_READ_SOCKET = nxt_port_handler_idx(read_socket),
122320Smax.romanov@nginx.com
1231488St.nateldemoura@f5.com NXT_PORT_MSG_MAX = sizeof(nxt_port_handlers_t)
1241488St.nateldemoura@f5.com / sizeof(nxt_port_handler_t),
125320Smax.romanov@nginx.com
1261488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_READY = _NXT_PORT_MSG_RPC_READY,
1271488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_READY_LAST = nxt_msg_last(_NXT_PORT_MSG_RPC_READY),
1281488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_ERROR = nxt_msg_last(_NXT_PORT_MSG_RPC_ERROR),
1291488St.nateldemoura@f5.com NXT_PORT_MSG_START_PROCESS = nxt_msg_last(_NXT_PORT_MSG_START_PROCESS),
1301488St.nateldemoura@f5.com NXT_PORT_MSG_SOCKET = nxt_msg_last(_NXT_PORT_MSG_SOCKET),
1312377Sa.clayton@nginx.com NXT_PORT_MSG_SOCKET_UNLINK = nxt_msg_last(_NXT_PORT_MSG_SOCKET_UNLINK),
1321488St.nateldemoura@f5.com NXT_PORT_MSG_MODULES = nxt_msg_last(_NXT_PORT_MSG_MODULES),
1331488St.nateldemoura@f5.com NXT_PORT_MSG_CONF_STORE = nxt_msg_last(_NXT_PORT_MSG_CONF_STORE),
1341488St.nateldemoura@f5.com NXT_PORT_MSG_CERT_GET = nxt_msg_last(_NXT_PORT_MSG_CERT_GET),
1351488St.nateldemoura@f5.com NXT_PORT_MSG_CERT_DELETE = nxt_msg_last(_NXT_PORT_MSG_CERT_DELETE),
136*2450Sz.hong@f5.com NXT_PORT_MSG_SCRIPT_GET = nxt_msg_last(_NXT_PORT_MSG_SCRIPT_GET),
137*2450Sz.hong@f5.com NXT_PORT_MSG_SCRIPT_DELETE = nxt_msg_last(_NXT_PORT_MSG_SCRIPT_DELETE),
1381488St.nateldemoura@f5.com NXT_PORT_MSG_ACCESS_LOG = nxt_msg_last(_NXT_PORT_MSG_ACCESS_LOG),
1391488St.nateldemoura@f5.com NXT_PORT_MSG_CHANGE_FILE = nxt_msg_last(_NXT_PORT_MSG_CHANGE_FILE),
1401488St.nateldemoura@f5.com NXT_PORT_MSG_NEW_PORT = nxt_msg_last(_NXT_PORT_MSG_NEW_PORT),
1411545Smax.romanov@nginx.com NXT_PORT_MSG_GET_PORT = nxt_msg_last(_NXT_PORT_MSG_GET_PORT),
1421666Smax.romanov@nginx.com NXT_PORT_MSG_PORT_ACK = nxt_msg_last(_NXT_PORT_MSG_PORT_ACK),
1431488St.nateldemoura@f5.com NXT_PORT_MSG_MMAP = nxt_msg_last(_NXT_PORT_MSG_MMAP)
1441547Smax.romanov@nginx.com | NXT_PORT_MSG_SYNC,
1451547Smax.romanov@nginx.com NXT_PORT_MSG_GET_MMAP = nxt_msg_last(_NXT_PORT_MSG_GET_MMAP),
146320Smax.romanov@nginx.com
1471488St.nateldemoura@f5.com NXT_PORT_MSG_PROCESS_CREATED = nxt_msg_last(_NXT_PORT_MSG_PROCESS_CREATED),
1481488St.nateldemoura@f5.com NXT_PORT_MSG_PROCESS_READY = nxt_msg_last(_NXT_PORT_MSG_PROCESS_READY),
1491998St.nateldemoura@f5.com NXT_PORT_MSG_WHOAMI = nxt_msg_last(_NXT_PORT_MSG_WHOAMI),
1501488St.nateldemoura@f5.com NXT_PORT_MSG_QUIT = nxt_msg_last(_NXT_PORT_MSG_QUIT),
1511488St.nateldemoura@f5.com NXT_PORT_MSG_REMOVE_PID = nxt_msg_last(_NXT_PORT_MSG_REMOVE_PID),
1521131Smax.romanov@nginx.com
1531488St.nateldemoura@f5.com NXT_PORT_MSG_REQ_HEADERS = _NXT_PORT_MSG_REQ_HEADERS,
1541555Smax.romanov@nginx.com NXT_PORT_MSG_REQ_BODY = _NXT_PORT_MSG_REQ_BODY,
1551488St.nateldemoura@f5.com NXT_PORT_MSG_WEBSOCKET = _NXT_PORT_MSG_WEBSOCKET,
1561488St.nateldemoura@f5.com NXT_PORT_MSG_WEBSOCKET_LAST = nxt_msg_last(_NXT_PORT_MSG_WEBSOCKET),
1571321Smax.romanov@nginx.com
1581488St.nateldemoura@f5.com NXT_PORT_MSG_DATA = _NXT_PORT_MSG_DATA,
1591488St.nateldemoura@f5.com NXT_PORT_MSG_DATA_LAST = nxt_msg_last(_NXT_PORT_MSG_DATA),
1601926Smax.romanov@nginx.com NXT_PORT_MSG_APP_RESTART = nxt_msg_last(_NXT_PORT_MSG_APP_RESTART),
1612185Svbart@nginx.com NXT_PORT_MSG_STATUS = nxt_msg_last(_NXT_PORT_MSG_STATUS),
1621488St.nateldemoura@f5.com
1631488St.nateldemoura@f5.com NXT_PORT_MSG_OOSM = nxt_msg_last(_NXT_PORT_MSG_OOSM),
1641488St.nateldemoura@f5.com NXT_PORT_MSG_SHM_ACK = nxt_msg_last(_NXT_PORT_MSG_SHM_ACK),
1651555Smax.romanov@nginx.com NXT_PORT_MSG_READ_QUEUE = _NXT_PORT_MSG_READ_QUEUE,
1661555Smax.romanov@nginx.com NXT_PORT_MSG_READ_SOCKET = _NXT_PORT_MSG_READ_SOCKET,
167125Smax.romanov@nginx.com } nxt_port_msg_type_t;
16842Smax.romanov@nginx.com
16914Sigor@sysoev.ru
17042Smax.romanov@nginx.com /* Passed as a first iov chunk. */
17142Smax.romanov@nginx.com typedef struct {
17242Smax.romanov@nginx.com uint32_t stream;
1731996St.nateldemoura@f5.com
1741996St.nateldemoura@f5.com nxt_pid_t pid; /* not used on Linux and FreeBSD */
1751996St.nateldemoura@f5.com
17642Smax.romanov@nginx.com nxt_port_id_t reply_port;
17742Smax.romanov@nginx.com
178189Smax.romanov@nginx.com uint8_t type;
179423Smax.romanov@nginx.com
180423Smax.romanov@nginx.com /* Last message for this stream. */
18142Smax.romanov@nginx.com uint8_t last; /* 1 bit */
18242Smax.romanov@nginx.com
18342Smax.romanov@nginx.com /* Message data send using mmap, next chunk is a nxt_port_mmap_msg_t. */
18442Smax.romanov@nginx.com uint8_t mmap; /* 1 bit */
185352Smax.romanov@nginx.com
186423Smax.romanov@nginx.com /* Non-First fragment in fragmented message sequence. */
187423Smax.romanov@nginx.com uint8_t nf; /* 1 bit */
188423Smax.romanov@nginx.com
189423Smax.romanov@nginx.com /* More Fragments followed. */
190423Smax.romanov@nginx.com uint8_t mf; /* 1 bit */
191168Svbart@nginx.com } nxt_port_msg_t;
19214Sigor@sysoev.ru
19314Sigor@sysoev.ru
19414Sigor@sysoev.ru typedef struct {
19514Sigor@sysoev.ru nxt_queue_link_t link;
19614Sigor@sysoev.ru nxt_buf_t *buf;
19714Sigor@sysoev.ru size_t share;
1981558Smax.romanov@nginx.com nxt_fd_t fd[2];
19914Sigor@sysoev.ru nxt_port_msg_t port_msg;
2001125Smax.romanov@nginx.com uint8_t close_fd; /* 1 bit */
2011125Smax.romanov@nginx.com uint8_t allocated; /* 1 bit */
20214Sigor@sysoev.ru } nxt_port_send_msg_t;
20314Sigor@sysoev.ru
2041996St.nateldemoura@f5.com #if (NXT_HAVE_UCRED) || (NXT_HAVE_MSGHDR_CMSGCRED)
2051996St.nateldemoura@f5.com #define NXT_USE_CMSG_PID 1
2061996St.nateldemoura@f5.com #endif
20714Sigor@sysoev.ru
20820Sigor@sysoev.ru struct nxt_port_recv_msg_s {
2091558Smax.romanov@nginx.com nxt_fd_t fd[2];
21014Sigor@sysoev.ru nxt_buf_t *buf;
21114Sigor@sysoev.ru nxt_port_t *port;
21242Smax.romanov@nginx.com nxt_port_msg_t port_msg;
21382Smax.romanov@nginx.com size_t size;
2141996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2151996St.nateldemoura@f5.com nxt_pid_t cmsg_pid;
2161996St.nateldemoura@f5.com #endif
217423Smax.romanov@nginx.com nxt_bool_t cancelled;
218347Smax.romanov@nginx.com union {
219347Smax.romanov@nginx.com nxt_port_t *new_port;
220347Smax.romanov@nginx.com nxt_pid_t removed_pid;
221347Smax.romanov@nginx.com void *data;
222347Smax.romanov@nginx.com } u;
22320Sigor@sysoev.ru };
22414Sigor@sysoev.ru
2251996St.nateldemoura@f5.com
2261996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2271996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg) ((msg)->cmsg_pid)
2281996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg) (&(msg)->cmsg_pid)
2291996St.nateldemoura@f5.com #else
2301996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg) ((msg)->port_msg.pid)
2311996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg) (NULL)
2321996St.nateldemoura@f5.com #endif
2331996St.nateldemoura@f5.com
234141Smax.romanov@nginx.com typedef struct nxt_app_s nxt_app_t;
23514Sigor@sysoev.ru
23614Sigor@sysoev.ru struct nxt_port_s {
23714Sigor@sysoev.ru nxt_fd_event_t socket;
23814Sigor@sysoev.ru
239125Smax.romanov@nginx.com nxt_queue_link_t link; /* for nxt_process_t.ports */
240141Smax.romanov@nginx.com nxt_process_t *process;
241141Smax.romanov@nginx.com
242141Smax.romanov@nginx.com nxt_queue_link_t app_link; /* for nxt_app_t.ports */
243141Smax.romanov@nginx.com nxt_app_t *app;
2441547Smax.romanov@nginx.com nxt_port_t *main_app_port;
24542Smax.romanov@nginx.com
246507Smax.romanov@nginx.com nxt_queue_link_t idle_link; /* for nxt_app_t.idle_ports */
247507Smax.romanov@nginx.com nxt_msec_t idle_start;
248507Smax.romanov@nginx.com
24914Sigor@sysoev.ru nxt_queue_t messages; /* of nxt_port_send_msg_t */
250343Smax.romanov@nginx.com nxt_thread_mutex_t write_mutex;
25114Sigor@sysoev.ru
25214Sigor@sysoev.ru /* Maximum size of message part. */
25314Sigor@sysoev.ru uint32_t max_size;
25414Sigor@sysoev.ru /* Maximum interleave of message parts. */
25514Sigor@sysoev.ru uint32_t max_share;
256343Smax.romanov@nginx.com
2571547Smax.romanov@nginx.com uint32_t active_websockets;
2581547Smax.romanov@nginx.com uint32_t active_requests;
2591131Smax.romanov@nginx.com
26014Sigor@sysoev.ru nxt_port_handler_t handler;
261141Smax.romanov@nginx.com nxt_port_handler_t *data;
26214Sigor@sysoev.ru
26365Sigor@sysoev.ru nxt_mp_t *mem_pool;
264141Smax.romanov@nginx.com nxt_event_engine_t *engine;
265141Smax.romanov@nginx.com
26614Sigor@sysoev.ru nxt_buf_t *free_bufs;
26714Sigor@sysoev.ru nxt_socket_t pair[2];
26814Sigor@sysoev.ru
26942Smax.romanov@nginx.com nxt_port_id_t id;
27014Sigor@sysoev.ru nxt_pid_t pid;
27142Smax.romanov@nginx.com
272190Smax.romanov@nginx.com nxt_lvlhsh_t rpc_streams; /* stream to nxt_port_rpc_reg_t */
273190Smax.romanov@nginx.com nxt_lvlhsh_t rpc_peers; /* peer to queue of nxt_port_rpc_reg_t */
274190Smax.romanov@nginx.com
275352Smax.romanov@nginx.com nxt_lvlhsh_t frags;
276352Smax.romanov@nginx.com
277343Smax.romanov@nginx.com nxt_atomic_t use_count;
278343Smax.romanov@nginx.com
279141Smax.romanov@nginx.com nxt_process_type_t type;
2801555Smax.romanov@nginx.com
2811555Smax.romanov@nginx.com nxt_fd_t queue_fd;
2821555Smax.romanov@nginx.com void *queue;
2831555Smax.romanov@nginx.com
2841555Smax.romanov@nginx.com void *socket_msg;
2851555Smax.romanov@nginx.com int from_socket;
28614Sigor@sysoev.ru };
28714Sigor@sysoev.ru
28814Sigor@sysoev.ru
28911Sigor@sysoev.ru typedef struct {
29042Smax.romanov@nginx.com nxt_port_id_t id;
29114Sigor@sysoev.ru nxt_pid_t pid;
29214Sigor@sysoev.ru size_t max_size;
29314Sigor@sysoev.ru size_t max_share;
29442Smax.romanov@nginx.com nxt_process_type_t type:8;
295168Svbart@nginx.com } nxt_port_msg_new_port_t;
29611Sigor@sysoev.ru
29711Sigor@sysoev.ru
2981545Smax.romanov@nginx.com typedef struct {
2991545Smax.romanov@nginx.com nxt_port_id_t id;
3001545Smax.romanov@nginx.com nxt_pid_t pid;
3011545Smax.romanov@nginx.com } nxt_port_msg_get_port_t;
3021545Smax.romanov@nginx.com
3031545Smax.romanov@nginx.com
3041546Smax.romanov@nginx.com typedef struct {
3051546Smax.romanov@nginx.com uint32_t id;
3061546Smax.romanov@nginx.com } nxt_port_msg_get_mmap_t;
3071546Smax.romanov@nginx.com
3081546Smax.romanov@nginx.com
30911Sigor@sysoev.ru /*
31014Sigor@sysoev.ru * nxt_port_data_t size is allocation size
31114Sigor@sysoev.ru * which enables effective reuse of memory pool cache.
31211Sigor@sysoev.ru */
31311Sigor@sysoev.ru typedef union {
31411Sigor@sysoev.ru nxt_buf_t buf;
31514Sigor@sysoev.ru nxt_port_msg_new_port_t new_port;
31614Sigor@sysoev.ru } nxt_port_data_t;
31711Sigor@sysoev.ru
31811Sigor@sysoev.ru
319343Smax.romanov@nginx.com typedef void (*nxt_port_post_handler_t)(nxt_task_t *task, nxt_port_t *port,
320343Smax.romanov@nginx.com void *data);
321343Smax.romanov@nginx.com
322197Smax.romanov@nginx.com nxt_port_t *nxt_port_new(nxt_task_t *task, nxt_port_id_t id, nxt_pid_t pid,
323163Smax.romanov@nginx.com nxt_process_type_t type);
324163Smax.romanov@nginx.com
325141Smax.romanov@nginx.com nxt_port_id_t nxt_port_get_next_id(void);
326141Smax.romanov@nginx.com void nxt_port_reset_next_id(void);
327141Smax.romanov@nginx.com
32814Sigor@sysoev.ru nxt_int_t nxt_port_socket_init(nxt_task_t *task, nxt_port_t *port,
32914Sigor@sysoev.ru size_t max_size);
33014Sigor@sysoev.ru void nxt_port_destroy(nxt_port_t *port);
331343Smax.romanov@nginx.com void nxt_port_close(nxt_task_t *task, nxt_port_t *port);
33214Sigor@sysoev.ru void nxt_port_write_enable(nxt_task_t *task, nxt_port_t *port);
33314Sigor@sysoev.ru void nxt_port_write_close(nxt_port_t *port);
33414Sigor@sysoev.ru void nxt_port_read_enable(nxt_task_t *task, nxt_port_t *port);
33514Sigor@sysoev.ru void nxt_port_read_close(nxt_port_t *port);
3361555Smax.romanov@nginx.com nxt_int_t nxt_port_socket_write2(nxt_task_t *task, nxt_port_t *port,
3371555Smax.romanov@nginx.com nxt_uint_t type, nxt_fd_t fd, nxt_fd_t fd2, uint32_t stream,
3381555Smax.romanov@nginx.com nxt_port_id_t reply_port, nxt_buf_t *b);
339423Smax.romanov@nginx.com
340423Smax.romanov@nginx.com nxt_inline nxt_int_t
nxt_port_socket_write(nxt_task_t * task,nxt_port_t * port,nxt_uint_t type,nxt_fd_t fd,uint32_t stream,nxt_port_id_t reply_port,nxt_buf_t * b)341423Smax.romanov@nginx.com nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port,
342423Smax.romanov@nginx.com nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_port_id_t reply_port,
343423Smax.romanov@nginx.com nxt_buf_t *b)
344423Smax.romanov@nginx.com {
3451555Smax.romanov@nginx.com return nxt_port_socket_write2(task, port, type, fd, -1, stream, reply_port,
3461555Smax.romanov@nginx.com b);
347423Smax.romanov@nginx.com }
34814Sigor@sysoev.ru
349141Smax.romanov@nginx.com void nxt_port_enable(nxt_task_t *task, nxt_port_t *port,
3501302St.nateldemoura@f5.com const nxt_port_handlers_t *handlers);
35181Smax.romanov@nginx.com nxt_int_t nxt_port_send_port(nxt_task_t *task, nxt_port_t *port,
352141Smax.romanov@nginx.com nxt_port_t *new_port, uint32_t stream);
35320Sigor@sysoev.ru void nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt,
35411Sigor@sysoev.ru nxt_uint_t slot, nxt_fd_t fd);
3551997St.nateldemoura@f5.com void nxt_port_remove_notify_others(nxt_task_t *task, nxt_process_t *process);
35611Sigor@sysoev.ru
35714Sigor@sysoev.ru void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35814Sigor@sysoev.ru void nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
359320Smax.romanov@nginx.com void nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
36014Sigor@sysoev.ru void nxt_port_change_log_file_handler(nxt_task_t *task,
36111Sigor@sysoev.ru nxt_port_recv_msg_t *msg);
36242Smax.romanov@nginx.com void nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
36314Sigor@sysoev.ru void nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
364125Smax.romanov@nginx.com void nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
36514Sigor@sysoev.ru void nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
36611Sigor@sysoev.ru
367343Smax.romanov@nginx.com nxt_int_t nxt_port_post(nxt_task_t *task, nxt_port_t *port,
368343Smax.romanov@nginx.com nxt_port_post_handler_t handler, void *data);
369343Smax.romanov@nginx.com void nxt_port_use(nxt_task_t *task, nxt_port_t *port, int i);
37011Sigor@sysoev.ru
nxt_port_inc_use(nxt_port_t * port)371425Smax.romanov@nginx.com nxt_inline void nxt_port_inc_use(nxt_port_t *port)
372425Smax.romanov@nginx.com {
373425Smax.romanov@nginx.com nxt_atomic_fetch_add(&port->use_count, 1);
374425Smax.romanov@nginx.com }
375425Smax.romanov@nginx.com
37611Sigor@sysoev.ru #endif /* _NXT_PORT_H_INCLUDED_ */
377