nxt_port.h (318:c2442f5e054d) nxt_port.h (320:d385755599d6)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_PORT_H_INCLUDED_
8#define _NXT_PORT_H_INCLUDED_
9
10
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_PORT_H_INCLUDED_
8#define _NXT_PORT_H_INCLUDED_
9
10
11struct nxt_port_handlers_s {
12 /* RPC responses. */
13 nxt_port_handler_t rpc_ready;
14 nxt_port_handler_t rpc_error;
15
16 /* Main process RPC requests. */
17 nxt_port_handler_t start_worker;
18 nxt_port_handler_t socket;
19 nxt_port_handler_t modules;
20 nxt_port_handler_t conf_store;
21
22 /* File descriptor exchange. */
23 nxt_port_handler_t change_file;
24 nxt_port_handler_t new_port;
25 nxt_port_handler_t mmap;
26
27 /* New process ready. */
28 nxt_port_handler_t process_ready;
29
30 /* Process exit/crash notification. */
31 nxt_port_handler_t remove_pid;
32
33 /* Stop process command. */
34 nxt_port_handler_t quit;
35
36 /* Various data. */
37 nxt_port_handler_t data;
38};
39
40
41#define nxt_port_handler_idx(name) \
42 ( &((nxt_port_handlers_t *) 0)->name - (nxt_port_handler_t *) 0)
43
44
11typedef enum {
12 NXT_PORT_MSG_LAST = 0x100,
13 NXT_PORT_MSG_CLOSE_FD = 0x200,
14 NXT_PORT_MSG_SYNC = 0x400,
15
16 NXT_PORT_MSG_MASK = 0xFF,
17
45typedef enum {
46 NXT_PORT_MSG_LAST = 0x100,
47 NXT_PORT_MSG_CLOSE_FD = 0x200,
48 NXT_PORT_MSG_SYNC = 0x400,
49
50 NXT_PORT_MSG_MASK = 0xFF,
51
18 _NXT_PORT_MSG_QUIT = 0,
19 _NXT_PORT_MSG_NEW_PORT,
20 _NXT_PORT_MSG_CHANGE_FILE,
21 _NXT_PORT_MSG_MMAP,
22 _NXT_PORT_MSG_DATA,
23 _NXT_PORT_MSG_REMOVE_PID,
24 _NXT_PORT_MSG_READY,
25 _NXT_PORT_MSG_START_WORKER,
26 _NXT_PORT_MSG_SOCKET,
27 _NXT_PORT_MSG_MODULES,
28 _NXT_PORT_MSG_CONF_STORE,
29 _NXT_PORT_MSG_RPC_READY,
30 _NXT_PORT_MSG_RPC_ERROR,
52 _NXT_PORT_MSG_RPC_READY = nxt_port_handler_idx(rpc_ready),
53 _NXT_PORT_MSG_RPC_ERROR = nxt_port_handler_idx(rpc_error),
31
54
32 NXT_PORT_MSG_MAX,
55 _NXT_PORT_MSG_START_WORKER = nxt_port_handler_idx(start_worker),
56 _NXT_PORT_MSG_SOCKET = nxt_port_handler_idx(socket),
57 _NXT_PORT_MSG_MODULES = nxt_port_handler_idx(modules),
58 _NXT_PORT_MSG_CONF_STORE = nxt_port_handler_idx(conf_store),
33
59
34 NXT_PORT_MSG_QUIT = _NXT_PORT_MSG_QUIT | NXT_PORT_MSG_LAST,
35 NXT_PORT_MSG_NEW_PORT = _NXT_PORT_MSG_NEW_PORT | NXT_PORT_MSG_LAST,
36 NXT_PORT_MSG_CHANGE_FILE = _NXT_PORT_MSG_CHANGE_FILE | NXT_PORT_MSG_LAST,
37 NXT_PORT_MSG_MMAP = _NXT_PORT_MSG_MMAP | NXT_PORT_MSG_LAST |
38 NXT_PORT_MSG_CLOSE_FD | NXT_PORT_MSG_SYNC,
39 NXT_PORT_MSG_DATA = _NXT_PORT_MSG_DATA,
40 NXT_PORT_MSG_DATA_LAST = _NXT_PORT_MSG_DATA | NXT_PORT_MSG_LAST,
41 NXT_PORT_MSG_REMOVE_PID = _NXT_PORT_MSG_REMOVE_PID | NXT_PORT_MSG_LAST,
42 NXT_PORT_MSG_READY = _NXT_PORT_MSG_READY | NXT_PORT_MSG_LAST,
60 _NXT_PORT_MSG_CHANGE_FILE = nxt_port_handler_idx(change_file),
61 _NXT_PORT_MSG_NEW_PORT = nxt_port_handler_idx(new_port),
62 _NXT_PORT_MSG_MMAP = nxt_port_handler_idx(mmap),
63
64 _NXT_PORT_MSG_PROCESS_READY = nxt_port_handler_idx(process_ready),
65 _NXT_PORT_MSG_REMOVE_PID = nxt_port_handler_idx(remove_pid),
66 _NXT_PORT_MSG_QUIT = nxt_port_handler_idx(quit),
67
68 _NXT_PORT_MSG_DATA = nxt_port_handler_idx(data),
69
70 NXT_PORT_MSG_MAX = sizeof(nxt_port_handlers_t) /
71 sizeof(nxt_port_handler_t),
72
73 NXT_PORT_MSG_RPC_READY = _NXT_PORT_MSG_RPC_READY,
74 NXT_PORT_MSG_RPC_READY_LAST = _NXT_PORT_MSG_RPC_READY | NXT_PORT_MSG_LAST,
75 NXT_PORT_MSG_RPC_ERROR = _NXT_PORT_MSG_RPC_ERROR | NXT_PORT_MSG_LAST,
76
43 NXT_PORT_MSG_START_WORKER = _NXT_PORT_MSG_START_WORKER |
44 NXT_PORT_MSG_LAST,
45 NXT_PORT_MSG_SOCKET = _NXT_PORT_MSG_SOCKET | NXT_PORT_MSG_LAST,
46 NXT_PORT_MSG_MODULES = _NXT_PORT_MSG_MODULES | NXT_PORT_MSG_LAST,
47 NXT_PORT_MSG_CONF_STORE = _NXT_PORT_MSG_CONF_STORE | NXT_PORT_MSG_LAST,
77 NXT_PORT_MSG_START_WORKER = _NXT_PORT_MSG_START_WORKER |
78 NXT_PORT_MSG_LAST,
79 NXT_PORT_MSG_SOCKET = _NXT_PORT_MSG_SOCKET | NXT_PORT_MSG_LAST,
80 NXT_PORT_MSG_MODULES = _NXT_PORT_MSG_MODULES | NXT_PORT_MSG_LAST,
81 NXT_PORT_MSG_CONF_STORE = _NXT_PORT_MSG_CONF_STORE | NXT_PORT_MSG_LAST,
48 NXT_PORT_MSG_RPC_READY = _NXT_PORT_MSG_RPC_READY,
49 NXT_PORT_MSG_RPC_READY_LAST = _NXT_PORT_MSG_RPC_READY | NXT_PORT_MSG_LAST,
50 NXT_PORT_MSG_RPC_ERROR = _NXT_PORT_MSG_RPC_ERROR | NXT_PORT_MSG_LAST,
82
83 NXT_PORT_MSG_CHANGE_FILE = _NXT_PORT_MSG_CHANGE_FILE | NXT_PORT_MSG_LAST,
84 NXT_PORT_MSG_NEW_PORT = _NXT_PORT_MSG_NEW_PORT | NXT_PORT_MSG_LAST,
85 NXT_PORT_MSG_MMAP = _NXT_PORT_MSG_MMAP | NXT_PORT_MSG_LAST |
86 NXT_PORT_MSG_CLOSE_FD | NXT_PORT_MSG_SYNC,
87
88 NXT_PORT_MSG_PROCESS_READY = _NXT_PORT_MSG_PROCESS_READY |
89 NXT_PORT_MSG_LAST,
90 NXT_PORT_MSG_QUIT = _NXT_PORT_MSG_QUIT | NXT_PORT_MSG_LAST,
91 NXT_PORT_MSG_REMOVE_PID = _NXT_PORT_MSG_REMOVE_PID | NXT_PORT_MSG_LAST,
92
93 NXT_PORT_MSG_DATA = _NXT_PORT_MSG_DATA,
94 NXT_PORT_MSG_DATA_LAST = _NXT_PORT_MSG_DATA | NXT_PORT_MSG_LAST,
51} nxt_port_msg_type_t;
52
53
54/* Passed as a first iov chunk. */
55typedef struct {
56 uint32_t stream;
57 nxt_pid_t pid;
58 nxt_port_id_t reply_port;

--- 105 unchanged lines hidden (view full) ---

164void nxt_port_write_close(nxt_port_t *port);
165void nxt_port_read_enable(nxt_task_t *task, nxt_port_t *port);
166void nxt_port_read_close(nxt_port_t *port);
167nxt_int_t nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port,
168 nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_port_id_t reply_port,
169 nxt_buf_t *b);
170
171void nxt_port_enable(nxt_task_t *task, nxt_port_t *port,
95} nxt_port_msg_type_t;
96
97
98/* Passed as a first iov chunk. */
99typedef struct {
100 uint32_t stream;
101 nxt_pid_t pid;
102 nxt_port_id_t reply_port;

--- 105 unchanged lines hidden (view full) ---

208void nxt_port_write_close(nxt_port_t *port);
209void nxt_port_read_enable(nxt_task_t *task, nxt_port_t *port);
210void nxt_port_read_close(nxt_port_t *port);
211nxt_int_t nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port,
212 nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_port_id_t reply_port,
213 nxt_buf_t *b);
214
215void nxt_port_enable(nxt_task_t *task, nxt_port_t *port,
172 nxt_port_handler_t *handlers);
216 nxt_port_handlers_t *handlers);
173void nxt_port_send_new_port(nxt_task_t *task, nxt_runtime_t *rt,
174 nxt_port_t *port, uint32_t stream);
175nxt_int_t nxt_port_send_port(nxt_task_t *task, nxt_port_t *port,
176 nxt_port_t *new_port, uint32_t stream);
177void nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt,
178 nxt_uint_t slot, nxt_fd_t fd);
179
180void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
181void nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
217void nxt_port_send_new_port(nxt_task_t *task, nxt_runtime_t *rt,
218 nxt_port_t *port, uint32_t stream);
219nxt_int_t nxt_port_send_port(nxt_task_t *task, nxt_port_t *port,
220 nxt_port_t *new_port, uint32_t stream);
221void nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt,
222 nxt_uint_t slot, nxt_fd_t fd);
223
224void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
225void nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
182void nxt_port_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
226void nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
183void nxt_port_change_log_file_handler(nxt_task_t *task,
184 nxt_port_recv_msg_t *msg);
185void nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
186void nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
187void nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
188void nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
189
190
191#endif /* _NXT_PORT_H_INCLUDED_ */
227void nxt_port_change_log_file_handler(nxt_task_t *task,
228 nxt_port_recv_msg_t *msg);
229void nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
230void nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
231void nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
232void nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
233
234
235#endif /* _NXT_PORT_H_INCLUDED_ */