0
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #ifndef _NGX_CONNECTION_H_INCLUDED_
|
|
8 #define _NGX_CONNECTION_H_INCLUDED_
|
|
9
|
|
10
|
|
11 #include <ngx_config.h>
|
|
12 #include <ngx_core.h>
|
|
13
|
|
14
|
92
|
15 typedef struct ngx_listening_s ngx_listening_t;
|
|
16
|
|
17 struct ngx_listening_s {
|
|
18 ngx_socket_t fd;
|
0
|
19
|
92
|
20 struct sockaddr *sockaddr;
|
|
21 socklen_t socklen; /* size of sockaddr */
|
|
22 size_t addr_text_max_len;
|
|
23 ngx_str_t addr_text;
|
0
|
24
|
92
|
25 int type;
|
112
|
26
|
92
|
27 int backlog;
|
112
|
28 int rcvbuf;
|
|
29 int sndbuf;
|
654
|
30 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
|
31 int keepidle;
|
|
32 int keepintvl;
|
|
33 int keepcnt;
|
|
34 #endif
|
0
|
35
|
92
|
36 /* handler of accepted connection */
|
96
|
37 ngx_connection_handler_pt handler;
|
92
|
38
|
|
39 void *servers; /* array of ngx_http_in_addr_t, for example */
|
0
|
40
|
92
|
41 ngx_log_t log;
|
484
|
42 ngx_log_t *logp;
|
0
|
43
|
92
|
44 size_t pool_size;
|
|
45 /* should be here because of the AcceptEx() preread */
|
|
46 size_t post_accept_buffer_size;
|
|
47 /* should be here because of the deferred accept */
|
106
|
48 ngx_msec_t post_accept_timeout;
|
92
|
49
|
|
50 ngx_listening_t *previous;
|
|
51 ngx_connection_t *connection;
|
0
|
52
|
92
|
53 unsigned open:1;
|
|
54 unsigned remain:1;
|
|
55 unsigned ignore:1;
|
0
|
56
|
92
|
57 unsigned bound:1; /* already bound */
|
|
58 unsigned inherited:1; /* inherited from previous process */
|
|
59 unsigned nonblocking_accept:1;
|
112
|
60 unsigned listen:1;
|
92
|
61 unsigned nonblocking:1;
|
|
62 unsigned shared:1; /* shared between threads or processes */
|
|
63 unsigned addr_ntop:1;
|
72
|
64
|
460
|
65 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
|
66 unsigned ipv6only:2;
|
|
67 #endif
|
654
|
68 unsigned keepalive:2;
|
460
|
69
|
18
|
70 #if (NGX_HAVE_DEFERRED_ACCEPT)
|
92
|
71 unsigned deferred_accept:1;
|
|
72 unsigned delete_deferred:1;
|
|
73 unsigned add_deferred:1;
|
72
|
74 #ifdef SO_ACCEPTFILTER
|
92
|
75 char *accept_filter;
|
72
|
76 #endif
|
0
|
77 #endif
|
584
|
78 #if (NGX_HAVE_SETFIB)
|
|
79 int setfib;
|
|
80 #endif
|
0
|
81
|
92
|
82 };
|
0
|
83
|
|
84
|
|
85 typedef enum {
|
460
|
86 NGX_ERROR_ALERT = 0,
|
0
|
87 NGX_ERROR_ERR,
|
|
88 NGX_ERROR_INFO,
|
460
|
89 NGX_ERROR_IGNORE_ECONNRESET,
|
|
90 NGX_ERROR_IGNORE_EINVAL
|
0
|
91 } ngx_connection_log_error_e;
|
|
92
|
|
93
|
|
94 typedef enum {
|
32
|
95 NGX_TCP_NODELAY_UNSET = 0,
|
|
96 NGX_TCP_NODELAY_SET,
|
|
97 NGX_TCP_NODELAY_DISABLED
|
|
98 } ngx_connection_tcp_nodelay_e;
|
|
99
|
|
100
|
|
101 typedef enum {
|
0
|
102 NGX_TCP_NOPUSH_UNSET = 0,
|
32
|
103 NGX_TCP_NOPUSH_SET,
|
|
104 NGX_TCP_NOPUSH_DISABLED
|
0
|
105 } ngx_connection_tcp_nopush_e;
|
|
106
|
|
107
|
254
|
108 #define NGX_LOWLEVEL_BUFFERED 0x0f
|
|
109 #define NGX_SSL_BUFFERED 0x01
|
146
|
110
|
|
111
|
0
|
112 struct ngx_connection_s {
|
|
113 void *data;
|
|
114 ngx_event_t *read;
|
|
115 ngx_event_t *write;
|
|
116
|
|
117 ngx_socket_t fd;
|
|
118
|
|
119 ngx_recv_pt recv;
|
88
|
120 ngx_send_pt send;
|
126
|
121 ngx_recv_chain_pt recv_chain;
|
0
|
122 ngx_send_chain_pt send_chain;
|
|
123
|
|
124 ngx_listening_t *listening;
|
|
125
|
|
126 off_t sent;
|
|
127
|
|
128 ngx_log_t *log;
|
|
129
|
|
130 ngx_pool_t *pool;
|
|
131
|
|
132 struct sockaddr *sockaddr;
|
|
133 socklen_t socklen;
|
|
134 ngx_str_t addr_text;
|
|
135
|
126
|
136 #if (NGX_SSL)
|
96
|
137 ngx_ssl_connection_t *ssl;
|
0
|
138 #endif
|
|
139
|
|
140 struct sockaddr *local_sockaddr;
|
|
141
|
|
142 ngx_buf_t *buffer;
|
|
143
|
618
|
144 ngx_queue_t queue;
|
|
145
|
44
|
146 ngx_atomic_uint_t number;
|
0
|
147
|
496
|
148 ngx_uint_t requests;
|
|
149
|
254
|
150 unsigned buffered:8;
|
146
|
151
|
460
|
152 unsigned log_error:3; /* ngx_connection_log_error_e */
|
0
|
153
|
|
154 unsigned single_connection:1;
|
|
155 unsigned unexpected_eof:1;
|
|
156 unsigned timedout:1;
|
132
|
157 unsigned error:1;
|
|
158 unsigned destroyed:1;
|
2
|
159
|
290
|
160 unsigned idle:1;
|
618
|
161 unsigned reusable:1;
|
290
|
162 unsigned close:1;
|
|
163
|
2
|
164 unsigned sendfile:1;
|
|
165 unsigned sndlowat:1;
|
32
|
166 unsigned tcp_nodelay:2; /* ngx_connection_tcp_nodelay_e */
|
|
167 unsigned tcp_nopush:2; /* ngx_connection_tcp_nopush_e */
|
2
|
168
|
18
|
169 #if (NGX_HAVE_IOCP)
|
0
|
170 unsigned accept_context_updated:1;
|
|
171 #endif
|
|
172
|
520
|
173 #if (NGX_HAVE_AIO_SENDFILE)
|
|
174 unsigned aio_sendfile:1;
|
|
175 ngx_buf_t *busy_sendfile;
|
|
176 #endif
|
|
177
|
0
|
178 #if (NGX_THREADS)
|
|
179 ngx_atomic_t lock;
|
|
180 #endif
|
|
181 };
|
|
182
|
|
183
|
486
|
184 ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr,
|
|
185 socklen_t socklen);
|
0
|
186 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle);
|
|
187 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle);
|
486
|
188 void ngx_configure_listening_sockets(ngx_cycle_t *cycle);
|
0
|
189 void ngx_close_listening_sockets(ngx_cycle_t *cycle);
|
|
190 void ngx_close_connection(ngx_connection_t *c);
|
492
|
191 ngx_int_t ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
|
|
192 ngx_uint_t port);
|
0
|
193 ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text);
|
|
194
|
92
|
195 ngx_connection_t *ngx_get_connection(ngx_socket_t s, ngx_log_t *log);
|
|
196 void ngx_free_connection(ngx_connection_t *c);
|
0
|
197
|
618
|
198 void ngx_reusable_connection(ngx_connection_t *c, ngx_uint_t reusable);
|
0
|
199
|
|
200 #endif /* _NGX_CONNECTION_H_INCLUDED_ */
|