xref: /unit/src/nxt_port.h (revision 1998)
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 */
177423Smax.romanov@nginx.com 
178423Smax.romanov@nginx.com     /* Message delivery tracking enabled, next chunk is tracking msg. */
179423Smax.romanov@nginx.com     uint8_t              tracking;  /* 1 bit */
180168Svbart@nginx.com } nxt_port_msg_t;
18114Sigor@sysoev.ru 
18214Sigor@sysoev.ru 
18314Sigor@sysoev.ru typedef struct {
18414Sigor@sysoev.ru     nxt_queue_link_t    link;
18514Sigor@sysoev.ru     nxt_buf_t           *buf;
18614Sigor@sysoev.ru     size_t              share;
1871558Smax.romanov@nginx.com     nxt_fd_t            fd[2];
18814Sigor@sysoev.ru     nxt_port_msg_t      port_msg;
189423Smax.romanov@nginx.com     uint32_t            tracking_msg[2];
1901125Smax.romanov@nginx.com     uint8_t             close_fd;   /* 1 bit */
1911125Smax.romanov@nginx.com     uint8_t             allocated;  /* 1 bit */
19214Sigor@sysoev.ru } nxt_port_send_msg_t;
19314Sigor@sysoev.ru 
1941996St.nateldemoura@f5.com #if (NXT_HAVE_UCRED) || (NXT_HAVE_MSGHDR_CMSGCRED)
1951996St.nateldemoura@f5.com #define NXT_USE_CMSG_PID    1
1961996St.nateldemoura@f5.com #endif
19714Sigor@sysoev.ru 
19820Sigor@sysoev.ru struct nxt_port_recv_msg_s {
1991558Smax.romanov@nginx.com     nxt_fd_t            fd[2];
20014Sigor@sysoev.ru     nxt_buf_t           *buf;
20114Sigor@sysoev.ru     nxt_port_t          *port;
20242Smax.romanov@nginx.com     nxt_port_msg_t      port_msg;
20382Smax.romanov@nginx.com     size_t              size;
2041996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2051996St.nateldemoura@f5.com     nxt_pid_t           cmsg_pid;
2061996St.nateldemoura@f5.com #endif
207423Smax.romanov@nginx.com     nxt_bool_t          cancelled;
208347Smax.romanov@nginx.com     union {
209347Smax.romanov@nginx.com         nxt_port_t      *new_port;
210347Smax.romanov@nginx.com         nxt_pid_t       removed_pid;
211347Smax.romanov@nginx.com         void            *data;
212347Smax.romanov@nginx.com     } u;
21320Sigor@sysoev.ru };
21414Sigor@sysoev.ru 
2151996St.nateldemoura@f5.com 
2161996St.nateldemoura@f5.com #if (NXT_USE_CMSG_PID)
2171996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg)      ((msg)->cmsg_pid)
2181996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg)  (&(msg)->cmsg_pid)
2191996St.nateldemoura@f5.com #else
2201996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid(msg)      ((msg)->port_msg.pid)
2211996St.nateldemoura@f5.com #define nxt_recv_msg_cmsg_pid_ref(msg)  (NULL)
2221996St.nateldemoura@f5.com #endif
2231996St.nateldemoura@f5.com 
224141Smax.romanov@nginx.com typedef struct nxt_app_s  nxt_app_t;
22514Sigor@sysoev.ru 
22614Sigor@sysoev.ru struct nxt_port_s {
22714Sigor@sysoev.ru     nxt_fd_event_t      socket;
22814Sigor@sysoev.ru 
229125Smax.romanov@nginx.com     nxt_queue_link_t    link;       /* for nxt_process_t.ports */
230141Smax.romanov@nginx.com     nxt_process_t       *process;
231141Smax.romanov@nginx.com 
232141Smax.romanov@nginx.com     nxt_queue_link_t    app_link;   /* for nxt_app_t.ports */
233141Smax.romanov@nginx.com     nxt_app_t           *app;
2341547Smax.romanov@nginx.com     nxt_port_t          *main_app_port;
23542Smax.romanov@nginx.com 
236507Smax.romanov@nginx.com     nxt_queue_link_t    idle_link;  /* for nxt_app_t.idle_ports */
237507Smax.romanov@nginx.com     nxt_msec_t          idle_start;
238507Smax.romanov@nginx.com 
23914Sigor@sysoev.ru     nxt_queue_t         messages;   /* of nxt_port_send_msg_t */
240343Smax.romanov@nginx.com     nxt_thread_mutex_t  write_mutex;
24114Sigor@sysoev.ru 
24214Sigor@sysoev.ru     /* Maximum size of message part. */
24314Sigor@sysoev.ru     uint32_t            max_size;
24414Sigor@sysoev.ru     /* Maximum interleave of message parts. */
24514Sigor@sysoev.ru     uint32_t            max_share;
246343Smax.romanov@nginx.com 
2471547Smax.romanov@nginx.com     uint32_t            active_websockets;
2481547Smax.romanov@nginx.com     uint32_t            active_requests;
2491131Smax.romanov@nginx.com 
25014Sigor@sysoev.ru     nxt_port_handler_t  handler;
251141Smax.romanov@nginx.com     nxt_port_handler_t  *data;
25214Sigor@sysoev.ru 
25365Sigor@sysoev.ru     nxt_mp_t            *mem_pool;
254141Smax.romanov@nginx.com     nxt_event_engine_t  *engine;
255141Smax.romanov@nginx.com 
25614Sigor@sysoev.ru     nxt_buf_t           *free_bufs;
25714Sigor@sysoev.ru     nxt_socket_t        pair[2];
25814Sigor@sysoev.ru 
25942Smax.romanov@nginx.com     nxt_port_id_t       id;
26014Sigor@sysoev.ru     nxt_pid_t           pid;
26142Smax.romanov@nginx.com 
262190Smax.romanov@nginx.com     nxt_lvlhsh_t        rpc_streams; /* stream to nxt_port_rpc_reg_t */
263190Smax.romanov@nginx.com     nxt_lvlhsh_t        rpc_peers;   /* peer to queue of nxt_port_rpc_reg_t */
264190Smax.romanov@nginx.com 
265352Smax.romanov@nginx.com     nxt_lvlhsh_t        frags;
266352Smax.romanov@nginx.com 
267343Smax.romanov@nginx.com     nxt_atomic_t        use_count;
268343Smax.romanov@nginx.com 
269141Smax.romanov@nginx.com     nxt_process_type_t  type;
2701555Smax.romanov@nginx.com 
2711555Smax.romanov@nginx.com     nxt_fd_t            queue_fd;
2721555Smax.romanov@nginx.com     void                *queue;
2731555Smax.romanov@nginx.com 
2741555Smax.romanov@nginx.com     void                *socket_msg;
2751555Smax.romanov@nginx.com     int                 from_socket;
27614Sigor@sysoev.ru };
27714Sigor@sysoev.ru 
27814Sigor@sysoev.ru 
27911Sigor@sysoev.ru typedef struct {
28042Smax.romanov@nginx.com     nxt_port_id_t       id;
28114Sigor@sysoev.ru     nxt_pid_t           pid;
28214Sigor@sysoev.ru     size_t              max_size;
28314Sigor@sysoev.ru     size_t              max_share;
28442Smax.romanov@nginx.com     nxt_process_type_t  type:8;
285168Svbart@nginx.com } nxt_port_msg_new_port_t;
28611Sigor@sysoev.ru 
28711Sigor@sysoev.ru 
2881545Smax.romanov@nginx.com typedef struct {
2891545Smax.romanov@nginx.com     nxt_port_id_t       id;
2901545Smax.romanov@nginx.com     nxt_pid_t           pid;
2911545Smax.romanov@nginx.com } nxt_port_msg_get_port_t;
2921545Smax.romanov@nginx.com 
2931545Smax.romanov@nginx.com 
2941546Smax.romanov@nginx.com typedef struct {
2951546Smax.romanov@nginx.com     uint32_t            id;
2961546Smax.romanov@nginx.com } nxt_port_msg_get_mmap_t;
2971546Smax.romanov@nginx.com 
2981546Smax.romanov@nginx.com 
29911Sigor@sysoev.ru /*
30014Sigor@sysoev.ru  * nxt_port_data_t size is allocation size
30114Sigor@sysoev.ru  * which enables effective reuse of memory pool cache.
30211Sigor@sysoev.ru  */
30311Sigor@sysoev.ru typedef union {
30411Sigor@sysoev.ru     nxt_buf_t                buf;
30514Sigor@sysoev.ru     nxt_port_msg_new_port_t  new_port;
30614Sigor@sysoev.ru } nxt_port_data_t;
30711Sigor@sysoev.ru 
30811Sigor@sysoev.ru 
309343Smax.romanov@nginx.com typedef void (*nxt_port_post_handler_t)(nxt_task_t *task, nxt_port_t *port,
310343Smax.romanov@nginx.com     void *data);
311343Smax.romanov@nginx.com 
312197Smax.romanov@nginx.com nxt_port_t *nxt_port_new(nxt_task_t *task, nxt_port_id_t id, nxt_pid_t pid,
313163Smax.romanov@nginx.com     nxt_process_type_t type);
314163Smax.romanov@nginx.com 
315141Smax.romanov@nginx.com nxt_port_id_t nxt_port_get_next_id(void);
316141Smax.romanov@nginx.com void nxt_port_reset_next_id(void);
317141Smax.romanov@nginx.com 
31814Sigor@sysoev.ru nxt_int_t nxt_port_socket_init(nxt_task_t *task, nxt_port_t *port,
31914Sigor@sysoev.ru     size_t max_size);
32014Sigor@sysoev.ru void nxt_port_destroy(nxt_port_t *port);
321343Smax.romanov@nginx.com void nxt_port_close(nxt_task_t *task, nxt_port_t *port);
32214Sigor@sysoev.ru void nxt_port_write_enable(nxt_task_t *task, nxt_port_t *port);
32314Sigor@sysoev.ru void nxt_port_write_close(nxt_port_t *port);
32414Sigor@sysoev.ru void nxt_port_read_enable(nxt_task_t *task, nxt_port_t *port);
32514Sigor@sysoev.ru void nxt_port_read_close(nxt_port_t *port);
3261555Smax.romanov@nginx.com nxt_int_t nxt_port_socket_write2(nxt_task_t *task, nxt_port_t *port,
3271555Smax.romanov@nginx.com     nxt_uint_t type, nxt_fd_t fd, nxt_fd_t fd2, uint32_t stream,
3281555Smax.romanov@nginx.com     nxt_port_id_t reply_port, nxt_buf_t *b);
329423Smax.romanov@nginx.com 
330423Smax.romanov@nginx.com nxt_inline nxt_int_t
331423Smax.romanov@nginx.com nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port,
332423Smax.romanov@nginx.com     nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_port_id_t reply_port,
333423Smax.romanov@nginx.com     nxt_buf_t *b)
334423Smax.romanov@nginx.com {
3351555Smax.romanov@nginx.com     return nxt_port_socket_write2(task, port, type, fd, -1, stream, reply_port,
3361555Smax.romanov@nginx.com                                   b);
337423Smax.romanov@nginx.com }
33814Sigor@sysoev.ru 
339141Smax.romanov@nginx.com void nxt_port_enable(nxt_task_t *task, nxt_port_t *port,
3401302St.nateldemoura@f5.com     const nxt_port_handlers_t *handlers);
34181Smax.romanov@nginx.com nxt_int_t nxt_port_send_port(nxt_task_t *task, nxt_port_t *port,
342141Smax.romanov@nginx.com     nxt_port_t *new_port, uint32_t stream);
34320Sigor@sysoev.ru void nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt,
34411Sigor@sysoev.ru     nxt_uint_t slot, nxt_fd_t fd);
3451997St.nateldemoura@f5.com void nxt_port_remove_notify_others(nxt_task_t *task, nxt_process_t *process);
34611Sigor@sysoev.ru 
34714Sigor@sysoev.ru void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
34814Sigor@sysoev.ru void nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
349320Smax.romanov@nginx.com void nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35014Sigor@sysoev.ru void nxt_port_change_log_file_handler(nxt_task_t *task,
35111Sigor@sysoev.ru     nxt_port_recv_msg_t *msg);
35242Smax.romanov@nginx.com void nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35314Sigor@sysoev.ru void nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
354125Smax.romanov@nginx.com void nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35514Sigor@sysoev.ru void nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
35611Sigor@sysoev.ru 
357343Smax.romanov@nginx.com nxt_int_t nxt_port_post(nxt_task_t *task, nxt_port_t *port,
358343Smax.romanov@nginx.com     nxt_port_post_handler_t handler, void *data);
359343Smax.romanov@nginx.com void nxt_port_use(nxt_task_t *task, nxt_port_t *port, int i);
36011Sigor@sysoev.ru 
361425Smax.romanov@nginx.com nxt_inline void nxt_port_inc_use(nxt_port_t *port)
362425Smax.romanov@nginx.com {
363425Smax.romanov@nginx.com     nxt_atomic_fetch_add(&port->use_count, 1);
364425Smax.romanov@nginx.com }
365425Smax.romanov@nginx.com 
36611Sigor@sysoev.ru #endif /* _NXT_PORT_H_INCLUDED_ */
367