summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port.h
blob: b195bcd7b90a136fdff6c1fd29f85511c68b98c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_PORT_H_INCLUDED_
#define _NXT_PORT_H_INCLUDED_


#define NXT_PORT_MSG_MAX  NXT_PORT_MSG_DATA

typedef enum {
    NXT_PORT_MSG_QUIT = 0,
    NXT_PORT_MSG_NEW_PORT,
    NXT_PORT_MSG_PORTGE_FILE,
    NXT_PORT_MSG_DATA,
} nxt_port_msg_type_e;


typedef struct {
    nxt_pid_t   pid;
    uint32_t    engine;
    uint32_t    generation;
    nxt_port_t  *port;
} nxt_process_port_t;


typedef struct {
    nxt_pid_t   pid;
    uint32_t    engine;
    size_t      max_size;
    size_t      max_share;
} nxt_proc_msg_new_port_t;


/*
 * nxt_process_port_data_t is allocaiton size
 * enabling effective reuse of memory pool cache.
 */
typedef union {
    nxt_buf_t                buf;
    nxt_proc_msg_new_port_t  new_port;
} nxt_process_port_data_t;


typedef void (*nxt_process_port_handler_t)(nxt_task_t *task,
    nxt_port_recv_msg_t *msg);


void nxt_process_port_create(nxt_thread_t *thr, nxt_process_port_t *proc,
    nxt_process_port_handler_t *handlers);
void nxt_process_port_write(nxt_task_t *task, nxt_cycle_t *cycle,
    nxt_uint_t type, nxt_fd_t fd, uint32_t stream, nxt_buf_t *b);
void nxt_process_new_port(nxt_task_t *task, nxt_cycle_t *cycle,
    nxt_process_port_t *proc);
void nxt_process_port_change_log_file(nxt_task_t *task, nxt_cycle_t *cycle,
    nxt_uint_t slot, nxt_fd_t fd);

void nxt_process_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
void nxt_process_port_new_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
void nxt_process_port_change_log_file_handler(nxt_task_t *task,
    nxt_port_recv_msg_t *msg);
void nxt_process_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
void nxt_process_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);


#endif /* _NXT_PORT_H_INCLUDED_ */