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;
19320Smax.romanov@nginx.com nxt_port_handler_t modules;
20320Smax.romanov@nginx.com nxt_port_handler_t conf_store;
21774Svbart@nginx.com nxt_port_handler_t cert_get;
22774Svbart@nginx.com nxt_port_handler_t cert_delete;
23630Svbart@nginx.com nxt_port_handler_t access_log;
24320Smax.romanov@nginx.com
25320Smax.romanov@nginx.com /* File descriptor exchange. */
26320Smax.romanov@nginx.com nxt_port_handler_t change_file;
27320Smax.romanov@nginx.com nxt_port_handler_t new_port;
281545Smax.romanov@nginx.com nxt_port_handler_t get_port;
291666Smax.romanov@nginx.com nxt_port_handler_t port_ack;
30320Smax.romanov@nginx.com nxt_port_handler_t mmap;
311546Smax.romanov@nginx.com nxt_port_handler_t get_mmap;
32320Smax.romanov@nginx.com
331488St.nateldemoura@f5.com /* New process */
341488St.nateldemoura@f5.com nxt_port_handler_t process_created;
35320Smax.romanov@nginx.com nxt_port_handler_t process_ready;
36*1998St.nateldemoura@f5.com nxt_port_handler_t whoami;
37320Smax.romanov@nginx.com
38320Smax.romanov@nginx.com /* Process exit/crash notification. */
39320Smax.romanov@nginx.com nxt_port_handler_t remove_pid;
40320Smax.romanov@nginx.com
41320Smax.romanov@nginx.com /* Stop process command. */
42320Smax.romanov@nginx.com nxt_port_handler_t quit;
43320Smax.romanov@nginx.com
441131Smax.romanov@nginx.com /* Request headers. */
451131Smax.romanov@nginx.com nxt_port_handler_t req_headers;
461547Smax.romanov@nginx.com nxt_port_handler_t req_headers_ack;
471555Smax.romanov@nginx.com nxt_port_handler_t req_body;
481131Smax.romanov@nginx.com
491131Smax.romanov@nginx.com /* Websocket frame. */
501131Smax.romanov@nginx.com nxt_port_handler_t websocket_frame;
511131Smax.romanov@nginx.com
52320Smax.romanov@nginx.com /* Various data. */
53320Smax.romanov@nginx.com nxt_port_handler_t data;
541926Smax.romanov@nginx.com nxt_port_handler_t app_restart;
551321Smax.romanov@nginx.com
561321Smax.romanov@nginx.com nxt_port_handler_t oosm;
571321Smax.romanov@nginx.com nxt_port_handler_t shm_ack;
581555Smax.romanov@nginx.com nxt_port_handler_t read_queue;
591555Smax.romanov@nginx.com nxt_port_handler_t read_socket;
60320Smax.romanov@nginx.com };
61320Smax.romanov@nginx.com
62320Smax.romanov@nginx.com
63320Smax.romanov@nginx.com #define nxt_port_handler_idx(name) \
64389Smax.romanov@nginx.com ( offsetof(nxt_port_handlers_t, name) / sizeof(nxt_port_handler_t) )
65320Smax.romanov@nginx.com
661488St.nateldemoura@f5.com #define nxt_msg_last(handler) \
671488St.nateldemoura@f5.com (handler | NXT_PORT_MSG_LAST)
68320Smax.romanov@nginx.com
6942Smax.romanov@nginx.com typedef enum {
701488St.nateldemoura@f5.com NXT_PORT_MSG_LAST = 0x100,
711488St.nateldemoura@f5.com NXT_PORT_MSG_CLOSE_FD = 0x200,
721488St.nateldemoura@f5.com NXT_PORT_MSG_SYNC = 0x400,
73189Smax.romanov@nginx.com
741488St.nateldemoura@f5.com NXT_PORT_MSG_MASK = 0xFF,
75189Smax.romanov@nginx.com
761488St.nateldemoura@f5.com _NXT_PORT_MSG_RPC_READY = nxt_port_handler_idx(rpc_ready),
771488St.nateldemoura@f5.com _NXT_PORT_MSG_RPC_ERROR = nxt_port_handler_idx(rpc_error),
78320Smax.romanov@nginx.com
791488St.nateldemoura@f5.com _NXT_PORT_MSG_START_PROCESS = nxt_port_handler_idx(start_process),
801488St.nateldemoura@f5.com _NXT_PORT_MSG_SOCKET = nxt_port_handler_idx(socket),
811488St.nateldemoura@f5.com _NXT_PORT_MSG_MODULES = nxt_port_handler_idx(modules),
821488St.nateldemoura@f5.com _NXT_PORT_MSG_CONF_STORE = nxt_port_handler_idx(conf_store),
831488St.nateldemoura@f5.com _NXT_PORT_MSG_CERT_GET = nxt_port_handler_idx(cert_get),
841488St.nateldemoura@f5.com _NXT_PORT_MSG_CERT_DELETE = nxt_port_handler_idx(cert_delete),
851488St.nateldemoura@f5.com _NXT_PORT_MSG_ACCESS_LOG = nxt_port_handler_idx(access_log),
8642Smax.romanov@nginx.com
871488St.nateldemoura@f5.com _NXT_PORT_MSG_CHANGE_FILE = nxt_port_handler_idx(change_file),
881488St.nateldemoura@f5.com _NXT_PORT_MSG_NEW_PORT = nxt_port_handler_idx(new_port),
891545Smax.romanov@nginx.com _NXT_PORT_MSG_GET_PORT = nxt_port_handler_idx(get_port),
901666Smax.romanov@nginx.com _NXT_PORT_MSG_PORT_ACK = nxt_port_handler_idx(port_ack),
911488St.nateldemoura@f5.com _NXT_PORT_MSG_MMAP = nxt_port_handler_idx(mmap),
921546Smax.romanov@nginx.com _NXT_PORT_MSG_GET_MMAP = nxt_port_handler_idx(get_mmap),
93320Smax.romanov@nginx.com
941488St.nateldemoura@f5.com _NXT_PORT_MSG_PROCESS_CREATED = nxt_port_handler_idx(process_created),
951488St.nateldemoura@f5.com _NXT_PORT_MSG_PROCESS_READY = nxt_port_handler_idx(process_ready),
96*1998St.nateldemoura@f5.com _NXT_PORT_MSG_WHOAMI = nxt_port_handler_idx(whoami),
971488St.nateldemoura@f5.com _NXT_PORT_MSG_REMOVE_PID = nxt_port_handler_idx(remove_pid),
981488St.nateldemoura@f5.com _NXT_PORT_MSG_QUIT = nxt_port_handler_idx(quit),
991131Smax.romanov@nginx.com
1001488St.nateldemoura@f5.com _NXT_PORT_MSG_REQ_HEADERS = nxt_port_handler_idx(req_headers),
1011547Smax.romanov@nginx.com _NXT_PORT_MSG_REQ_HEADERS_ACK = nxt_port_handler_idx(req_headers_ack),
1021555Smax.romanov@nginx.com _NXT_PORT_MSG_REQ_BODY = nxt_port_handler_idx(req_body),
1031488St.nateldemoura@f5.com _NXT_PORT_MSG_WEBSOCKET = nxt_port_handler_idx(websocket_frame),
104189Smax.romanov@nginx.com
1051488St.nateldemoura@f5.com _NXT_PORT_MSG_DATA = nxt_port_handler_idx(data),
1061926Smax.romanov@nginx.com _NXT_PORT_MSG_APP_RESTART = nxt_port_handler_idx(app_restart),
1071321Smax.romanov@nginx.com
1081488St.nateldemoura@f5.com _NXT_PORT_MSG_OOSM = nxt_port_handler_idx(oosm),
1091488St.nateldemoura@f5.com _NXT_PORT_MSG_SHM_ACK = nxt_port_handler_idx(shm_ack),
1101555Smax.romanov@nginx.com _NXT_PORT_MSG_READ_QUEUE = nxt_port_handler_idx(read_queue),
1111555Smax.romanov@nginx.com _NXT_PORT_MSG_READ_SOCKET = nxt_port_handler_idx(read_socket),
112320Smax.romanov@nginx.com
1131488St.nateldemoura@f5.com NXT_PORT_MSG_MAX = sizeof(nxt_port_handlers_t)
1141488St.nateldemoura@f5.com / sizeof(nxt_port_handler_t),
115320Smax.romanov@nginx.com
1161488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_READY = _NXT_PORT_MSG_RPC_READY,
1171488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_READY_LAST = nxt_msg_last(_NXT_PORT_MSG_RPC_READY),
1181488St.nateldemoura@f5.com NXT_PORT_MSG_RPC_ERROR = nxt_msg_last(_NXT_PORT_MSG_RPC_ERROR),
1191488St.nateldemoura@f5.com NXT_PORT_MSG_START_PROCESS = nxt_msg_last(_NXT_PORT_MSG_START_PROCESS),
1201488St.nateldemoura@f5.com NXT_PORT_MSG_SOCKET = nxt_msg_last(_NXT_PORT_MSG_SOCKET),
1211488St.nateldemoura@f5.com NXT_PORT_MSG_MODULES = nxt_msg_last(_NXT_PORT_MSG_MODULES),
1221488St.nateldemoura@f5.com NXT_PORT_MSG_CONF_STORE = nxt_msg_last(_NXT_PORT_MSG_CONF_STORE),
1231488St.nateldemoura@f5.com NXT_PORT_MSG_CERT_GET = nxt_msg_last(_NXT_PORT_MSG_CERT_GET),
1241488St.nateldemoura@f5.com NXT_PORT_MSG_CERT_DELETE = nxt_msg_last(_NXT_PORT_MSG_CERT_DELETE),
1251488St.nateldemoura@f5.com NXT_PORT_MSG_ACCESS_LOG = nxt_msg_last(_NXT_PORT_MSG_ACCESS_LOG),
1261488St.nateldemoura@f5.com NXT_PORT_MSG_CHANGE_FILE = nxt_msg_last(_NXT_PORT_MSG_CHANGE_FILE),
1271488St.nateldemoura@f5.com NXT_PORT_MSG_NEW_PORT = nxt_msg_last(_NXT_PORT_MSG_NEW_PORT),
1281545Smax.romanov@nginx.com NXT_PORT_MSG_GET_PORT = nxt_msg_last(_NXT_PORT_MSG_GET_PORT),
1291666Smax.romanov@nginx.com NXT_PORT_MSG_PORT_ACK = nxt_msg_last(_NXT_PORT_MSG_PORT_ACK),
1301488St.nateldemoura@f5.com NXT_PORT_MSG_MMAP = nxt_msg_last(_NXT_PORT_MSG_MMAP)
1311547Smax.romanov@nginx.com | NXT_PORT_MSG_SYNC,
1321547Smax.romanov@nginx.com NXT_PORT_MSG_GET_MMAP = nxt_msg_last(_NXT_PORT_MSG_GET_MMAP),
133320Smax.romanov@nginx.com
1341488St.nateldemoura@f5.com NXT_PORT_MSG_PROCESS_CREATED = nxt_msg_last(_NXT_PORT_MSG_PROCESS_CREATED),
1351488St.nateldemoura@f5.com NXT_PORT_MSG_PROCESS_READY = nxt_msg_last(_NXT_PORT_MSG_PROCESS_READY),
136*1998St.nateldemoura@f5.com NXT_PORT_MSG_WHOAMI = nxt_msg_last(_NXT_PORT_MSG_WHOAMI),
1371488St.nateldemoura@f5.com NXT_PORT_MSG_QUIT = nxt_msg_last(_NXT_PORT_MSG_QUIT),
1381488St.nateldemoura@f5.com NXT_PORT_MSG_REMOVE_PID = nxt_msg_last(_NXT_PORT_MSG_REMOVE_PID),
1391131Smax.romanov@nginx.com
1401488St.nateldemoura@f5.com NXT_PORT_MSG_REQ_HEADERS = _NXT_PORT_MSG_REQ_HEADERS,
1411555Smax.romanov@nginx.com NXT_PORT_MSG_REQ_BODY = _NXT_PORT_MSG_REQ_BODY,
1421488St.nateldemoura@f5.com NXT_PORT_MSG_WEBSOCKET = _NXT_PORT_MSG_WEBSOCKET,
1431488St.nateldemoura@f5.com NXT_PORT_MSG_WEBSOCKET_LAST = nxt_msg_last(_NXT_PORT_MSG_WEBSOCKET),
1441321Smax.romanov@nginx.com
1451488St.nateldemoura@f5.com NXT_PORT_MSG_DATA = _NXT_PORT_MSG_DATA,
1461488St.nateldemoura@f5.com NXT_PORT_MSG_DATA_LAST = nxt_msg_last(_NXT_PORT_MSG_DATA),
1471926Smax.romanov@nginx.com NXT_PORT_MSG_APP_RESTART = nxt_msg_last(_NXT_PORT_MSG_APP_RESTART),
1481488St.nateldemoura@f5.com
1491488St.nateldemoura@f5.com NXT_PORT_MSG_OOSM = nxt_msg_last(_NXT_PORT_MSG_OOSM),
1501488St.nateldemoura@f5.com NXT_PORT_MSG_SHM_ACK = nxt_msg_last(_NXT_PORT_MSG_SHM_ACK),
1511555Smax.romanov@nginx.com NXT_PORT_MSG_READ_QUEUE = _NXT_PORT_MSG_READ_QUEUE,
1521555Smax.romanov@nginx.com NXT_PORT_MSG_READ_SOCKET = _NXT_PORT_MSG_READ_SOCKET,
153125Smax.romanov@nginx.com } nxt_port_msg_type_t;
15442Smax.romanov@nginx.com
15514Sigor@sysoev.ru
15642Smax.romanov@nginx.com /* Passed as a first iov chunk. */
15742Smax.romanov@nginx.com typedef struct {
15842Smax.romanov@nginx.com uint32_t stream;
1591996St.nateldemoura@f5.com
1601996St.nateldemoura@f5.com nxt_pid_t pid; /* not used on Linux and FreeBSD */
1611996St.nateldemoura@f5.com
16242Smax.romanov@nginx.com nxt_port_id_t reply_port;
16342Smax.romanov@nginx.com
164189Smax.romanov@nginx.com uint8_t type;
165423Smax.romanov@nginx.com
166423Smax.romanov@nginx.com /* Last message for this stream. */
16742Smax.romanov@nginx.com uint8_t last; /* 1 bit */
16842Smax.romanov@nginx.com
16942Smax.romanov@nginx.com /* Message data send using mmap, next chunk is a nxt_port_mmap_msg_t. */
17042Smax.romanov@nginx.com uint8_t mmap; /* 1 bit */
171352Smax.romanov@nginx.com
172423Smax.romanov@nginx.com /* Non-First fragment in fragmented message sequence. */
173423Smax.romanov@nginx.com uint8_t nf; /* 1 bit */
174423Smax.romanov@nginx.com
175423Smax.romanov@nginx.com /* More Fragments followed. */
176423Smax.romanov@nginx.com uint8_t mf; /* 1 bit */
177168Svbart@nginx.com } nxt_port_msg_t;
17814Sigor@sysoev.ru
17914Sigor@sysoev.ru
18014Sigor@sysoev.ru typedef struct {
18114Sigor@sysoev.ru nxt_queue_link_t link;
18214Sigor@sysoev.ru nxt_buf_t *buf;
18314Sigor@sysoev.ru size_t share;
1841558Smax.romanov@nginx.com nxt_fd_t fd[2];
18514Sigor@sysoev.ru nxt_port_msg_t port_msg;
1861125Smax.romanov@nginx.com uint8_t close_fd; /* 1 bit */
1871125Smax.romanov@nginx.com uint8_t allocated; /* 1 bit */
18814Sigor@sysoev.ru } nxt_port_send_msg_t;
18914Sigor@sysoev.ru
1901996St.nateldemoura@f5.com #if (NXT_HAVE_UCRED) || (NXT_HAVE_MSGHDR_CMSGCRED)
1911996St.nateldemoura@f5.com #define NXT_USE_CMSG_PID 1
1921996St.nateldemoura@f5.com #endif
19314Sigor@sysoev.ru
19420Sigor@sysoev.ru struct nxt_port_recv_msg_s {
1951558Smax.romanov@nginx.com nxt_fd_t fd[2];
19614Sigor@sysoev.ru nxt_buf_t *buf;
19714Sigor@sysoev.ru nxt_port_t *port;
19842Smax.romanov@nginx.com nxt_port_msg_t port_msg;
19982Smax.romanov@nginx.com size_t size;
2001996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2011996St.nateldemoura@f5.com nxt_pid_t cmsg_pid;
2021996St.nateldemoura@f5.com #endif
203423Smax.romanov@nginx.com nxt_bool_t cancelled;
204347Smax.romanov@nginx.com union {
205347Smax.romanov@nginx.com nxt_port_t *new_port;
206347Smax.romanov@nginx.com nxt_pid_t removed_pid;
207347Smax.romanov@nginx.com void *data;
208347Smax.romanov@nginx.com } u;
20920Sigor@sysoev.ru };
21014Sigor@sysoev.ru
2111996St.nateldemoura@f5.com
2121996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2131996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg) ((msg)->cmsg_pid)
2141996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg) (&(msg)->cmsg_pid)
2151996St.nateldemoura@f5.com #else
2161996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg) ((msg)->port_msg.pid)
2171996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg) (NULL)
2181996St.nateldemoura@f5.com #endif
2191996St.nateldemoura@f5.com
220141Smax.romanov@nginx.com typedef struct nxt_app_s nxt_app_t;
22114Sigor@sysoev.ru
22214Sigor@sysoev.ru struct nxt_port_s {
22314Sigor@sysoev.ru nxt_fd_event_t socket;
22414Sigor@sysoev.ru
225125Smax.romanov@nginx.com nxt_queue_link_t link; /* for nxt_process_t.ports */
226141Smax.romanov@nginx.com nxt_process_t *process;
227141Smax.romanov@nginx.com
228141Smax.romanov@nginx.com nxt_queue_link_t app_link; /* for nxt_app_t.ports */
229141Smax.romanov@nginx.com nxt_app_t *app;
2301547Smax.romanov@nginx.com nxt_port_t *main_app_port;
23142Smax.romanov@nginx.com
232507Smax.romanov@nginx.com nxt_queue_link_t idle_link; /* for nxt_app_t.idle_ports */
233507Smax.romanov@nginx.com nxt_msec_t idle_start;
234507Smax.romanov@nginx.com
23514Sigor@sysoev.ru nxt_queue_t messages; /* of nxt_port_send_msg_t */
236343Smax.romanov@nginx.com nxt_thread_mutex_t write_mutex;
23714Sigor@sysoev.ru
23814Sigor@sysoev.ru /* Maximum size of message part. */
23914Sigor@sysoev.ru uint32_t max_size;
24014Sigor@sysoev.ru /* Maximum interleave of message parts. */
24114Sigor@sysoev.ru uint32_t max_share;
242343Smax.romanov@nginx.com
2431547Smax.romanov@nginx.com uint32_t active_websockets;
2441547Smax.romanov@nginx.com uint32_t active_requests;
2451131Smax.romanov@nginx.com
24614Sigor@sysoev.ru nxt_port_handler_t handler;
247141Smax.romanov@nginx.com nxt_port_handler_t *data;
24814Sigor@sysoev.ru
24965Sigor@sysoev.ru nxt_mp_t *mem_pool;
250141Smax.romanov@nginx.com nxt_event_engine_t *engine;
251141Smax.romanov@nginx.com
25214Sigor@sysoev.ru nxt_buf_t *free_bufs;
25314Sigor@sysoev.ru nxt_socket_t pair[2];
25414Sigor@sysoev.ru
25542Smax.romanov@nginx.com nxt_port_id_t id;
25614Sigor@sysoev.ru nxt_pid_t pid;
25742Smax.romanov@nginx.com
258190Smax.romanov@nginx.com nxt_lvlhsh_t rpc_streams; /* stream to nxt_port_rpc_reg_t */
259190Smax.romanov@nginx.com nxt_lvlhsh_t rpc_peers; /* peer to queue of nxt_port_rpc_reg_t */
260190Smax.romanov@nginx.com
261352Smax.romanov@nginx.com nxt_lvlhsh_t frags;
262352Smax.romanov@nginx.com
263343Smax.romanov@nginx.com nxt_atomic_t use_count;
264343Smax.romanov@nginx.com
265141Smax.romanov@nginx.com nxt_process_type_t type;
2661555Smax.romanov@nginx.com
2671555Smax.romanov@nginx.com nxt_fd_t queue_fd;
2681555Smax.romanov@nginx.com void *queue;
2691555Smax.romanov@nginx.com
2701555Smax.romanov@nginx.com void *socket_msg;
2711555Smax.romanov@nginx.com int from_socket;
27214Sigor@sysoev.ru };
27314Sigor@sysoev.ru
27414Sigor@sysoev.ru
27511Sigor@sysoev.ru typedef struct {
27642Smax.romanov@nginx.com nxt_port_id_t id;
27714Sigor@sysoev.ru nxt_pid_t pid;
27814Sigor@sysoev.ru size_t max_size;
27914Sigor@sysoev.ru size_t max_share;
28042Smax.romanov@nginx.com nxt_process_type_t type:8;
281168Svbart@nginx.com } nxt_port_msg_new_port_t;
28211Sigor@sysoev.ru
28311Sigor@sysoev.ru
2841545Smax.romanov@nginx.com typedef struct {
2851545Smax.romanov@nginx.com nxt_port_id_t id;
2861545Smax.romanov@nginx.com nxt_pid_t pid;
2871545Smax.romanov@nginx.com } nxt_port_msg_get_port_t;
2881545Smax.romanov@nginx.com
2891545Smax.romanov@nginx.com
2901546Smax.romanov@nginx.com typedef struct {
2911546Smax.romanov@nginx.com uint32_t id;
2921546Smax.romanov@nginx.com } nxt_port_msg_get_mmap_t;
2931546Smax.romanov@nginx.com
2941546Smax.romanov@nginx.com
29511Sigor@sysoev.ru /*
29614Sigor@sysoev.ru * nxt_port_data_t size is allocation size
29714Sigor@sysoev.ru * which enables effective reuse of memory pool cache.
29811Sigor@sysoev.ru */
29911Sigor@sysoev.ru typedef union {
30011Sigor@sysoev.ru nxt_buf_t buf;
30114Sigor@sysoev.ru nxt_port_msg_new_port_t new_port;
30214Sigor@sysoev.ru } nxt_port_data_t;
30311Sigor@sysoev.ru
30411Sigor@sysoev.ru
305343Smax.romanov@nginx.com typedef void (*nxt_port_post_handler_t)(nxt_task_t *task, nxt_port_t *port,
306343Smax.romanov@nginx.com void *data);
307343Smax.romanov@nginx.com
308197Smax.romanov@nginx.com nxt_port_t *nxt_port_new(nxt_task_t *task, nxt_port_id_t id, nxt_pid_t pid,
309163Smax.romanov@nginx.com nxt_process_type_t type);
310163Smax.romanov@nginx.com
311141Smax.romanov@nginx.com nxt_port_id_t nxt_port_get_next_id(void);
312141Smax.romanov@nginx.com void nxt_port_reset_next_id(void);
313141Smax.romanov@nginx.com
31414Sigor@sysoev.ru nxt_int_t nxt_port_socket_init(nxt_task_t *task, nxt_port_t *port,
31514Sigor@sysoev.ru size_t max_size);
31614Sigor@sysoev.ru void nxt_port_destroy(nxt_port_t *port);
317343Smax.romanov@nginx.com void nxt_port_close(nxt_task_t *task, nxt_port_t *port);
31814Sigor@sysoev.ru void nxt_port_write_enable(nxt_task_t *task, nxt_port_t *port);
31914Sigor@sysoev.ru void nxt_port_write_close(nxt_port_t *port);
32014Sigor@sysoev.ru void nxt_port_read_enable(nxt_task_t *task, nxt_port_t *port);
32114Sigor@sysoev.ru void nxt_port_read_close(nxt_port_t *port);
3221555Smax.romanov@nginx.com nxt_int_t nxt_port_socket_write2(nxt_task_t *task, nxt_port_t *port,
3231555Smax.romanov@nginx.com nxt_uint_t type, nxt_fd_t fd, nxt_fd_t fd2, uint32_t stream,
3241555Smax.romanov@nginx.com nxt_port_id_t reply_port, nxt_buf_t *b);
325423Smax.romanov@nginx.com
326423Smax.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)327423Smax.romanov@nginx.com nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port,
328423Smax.romanov@nginx.com nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_port_id_t reply_port,
329423Smax.romanov@nginx.com nxt_buf_t *b)
330423Smax.romanov@nginx.com {
3311555Smax.romanov@nginx.com return nxt_port_socket_write2(task, port, type, fd, -1, stream, reply_port,
3321555Smax.romanov@nginx.com b);
333423Smax.romanov@nginx.com }
33414Sigor@sysoev.ru
335141Smax.romanov@nginx.com void nxt_port_enable(nxt_task_t *task, nxt_port_t *port,
3361302St.nateldemoura@f5.com const nxt_port_handlers_t *handlers);
33781Smax.romanov@nginx.com nxt_int_t nxt_port_send_port(nxt_task_t *task, nxt_port_t *port,
338141Smax.romanov@nginx.com nxt_port_t *new_port, uint32_t stream);
33920Sigor@sysoev.ru void nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt,
34011Sigor@sysoev.ru nxt_uint_t slot, nxt_fd_t fd);
3411997St.nateldemoura@f5.com void nxt_port_remove_notify_others(nxt_task_t *task, nxt_process_t *process);
34211Sigor@sysoev.ru
34314Sigor@sysoev.ru void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
34414Sigor@sysoev.ru void nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
345320Smax.romanov@nginx.com void nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
34614Sigor@sysoev.ru void nxt_port_change_log_file_handler(nxt_task_t *task,
34711Sigor@sysoev.ru nxt_port_recv_msg_t *msg);
34842Smax.romanov@nginx.com void nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
34914Sigor@sysoev.ru void nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
350125Smax.romanov@nginx.com void nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35114Sigor@sysoev.ru void nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35211Sigor@sysoev.ru
353343Smax.romanov@nginx.com nxt_int_t nxt_port_post(nxt_task_t *task, nxt_port_t *port,
354343Smax.romanov@nginx.com nxt_port_post_handler_t handler, void *data);
355343Smax.romanov@nginx.com void nxt_port_use(nxt_task_t *task, nxt_port_t *port, int i);
35611Sigor@sysoev.ru
nxt_port_inc_use(nxt_port_t * port)357425Smax.romanov@nginx.com nxt_inline void nxt_port_inc_use(nxt_port_t *port)
358425Smax.romanov@nginx.com {
359425Smax.romanov@nginx.com nxt_atomic_fetch_add(&port->use_count, 1);
360425Smax.romanov@nginx.com }
361425Smax.romanov@nginx.com
36211Sigor@sysoev.ru #endif /* _NXT_PORT_H_INCLUDED_ */
363