Update and clean Tomato RAF files
[tomato.git] / release / src / router / nginx / src / core / ngx_connection.h
blob3daf2eee4cbb82f9d6cd2b7651cecfc6e00cd9ff
2 /*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
5 */
8 #ifndef _NGX_CONNECTION_H_INCLUDED_
9 #define _NGX_CONNECTION_H_INCLUDED_
12 #include <ngx_config.h>
13 #include <ngx_core.h>
16 typedef struct ngx_listening_s ngx_listening_t;
18 struct ngx_listening_s {
19 ngx_socket_t fd;
21 struct sockaddr *sockaddr;
22 socklen_t socklen; /* size of sockaddr */
23 size_t addr_text_max_len;
24 ngx_str_t addr_text;
26 int type;
28 int backlog;
29 int rcvbuf;
30 int sndbuf;
31 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
32 int keepidle;
33 int keepintvl;
34 int keepcnt;
35 #endif
37 /* handler of accepted connection */
38 ngx_connection_handler_pt handler;
40 void *servers; /* array of ngx_http_in_addr_t, for example */
42 ngx_log_t log;
43 ngx_log_t *logp;
45 size_t pool_size;
46 /* should be here because of the AcceptEx() preread */
47 size_t post_accept_buffer_size;
48 /* should be here because of the deferred accept */
49 ngx_msec_t post_accept_timeout;
51 ngx_listening_t *previous;
52 ngx_connection_t *connection;
54 unsigned open:1;
55 unsigned remain:1;
56 unsigned ignore:1;
58 unsigned bound:1; /* already bound */
59 unsigned inherited:1; /* inherited from previous process */
60 unsigned nonblocking_accept:1;
61 unsigned listen:1;
62 unsigned nonblocking:1;
63 unsigned shared:1; /* shared between threads or processes */
64 unsigned addr_ntop:1;
66 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
67 unsigned ipv6only:1;
68 #endif
69 unsigned keepalive:2;
71 #if (NGX_HAVE_DEFERRED_ACCEPT)
72 unsigned deferred_accept:1;
73 unsigned delete_deferred:1;
74 unsigned add_deferred:1;
75 #ifdef SO_ACCEPTFILTER
76 char *accept_filter;
77 #endif
78 #endif
79 #if (NGX_HAVE_SETFIB)
80 int setfib;
81 #endif
86 typedef enum {
87 NGX_ERROR_ALERT = 0,
88 NGX_ERROR_ERR,
89 NGX_ERROR_INFO,
90 NGX_ERROR_IGNORE_ECONNRESET,
91 NGX_ERROR_IGNORE_EINVAL
92 } ngx_connection_log_error_e;
95 typedef enum {
96 NGX_TCP_NODELAY_UNSET = 0,
97 NGX_TCP_NODELAY_SET,
98 NGX_TCP_NODELAY_DISABLED
99 } ngx_connection_tcp_nodelay_e;
102 typedef enum {
103 NGX_TCP_NOPUSH_UNSET = 0,
104 NGX_TCP_NOPUSH_SET,
105 NGX_TCP_NOPUSH_DISABLED
106 } ngx_connection_tcp_nopush_e;
109 #define NGX_LOWLEVEL_BUFFERED 0x0f
110 #define NGX_SSL_BUFFERED 0x01
113 struct ngx_connection_s {
114 void *data;
115 ngx_event_t *read;
116 ngx_event_t *write;
118 ngx_socket_t fd;
120 ngx_recv_pt recv;
121 ngx_send_pt send;
122 ngx_recv_chain_pt recv_chain;
123 ngx_send_chain_pt send_chain;
125 ngx_listening_t *listening;
127 off_t sent;
129 ngx_log_t *log;
131 ngx_pool_t *pool;
133 struct sockaddr *sockaddr;
134 socklen_t socklen;
135 ngx_str_t addr_text;
137 #if (NGX_SSL)
138 ngx_ssl_connection_t *ssl;
139 #endif
141 struct sockaddr *local_sockaddr;
143 ngx_buf_t *buffer;
145 ngx_queue_t queue;
147 ngx_atomic_uint_t number;
149 ngx_uint_t requests;
151 unsigned buffered:8;
153 unsigned log_error:3; /* ngx_connection_log_error_e */
155 unsigned unexpected_eof:1;
156 unsigned timedout:1;
157 unsigned error:1;
158 unsigned destroyed:1;
160 unsigned idle:1;
161 unsigned reusable:1;
162 unsigned close:1;
164 unsigned sendfile:1;
165 unsigned sndlowat:1;
166 unsigned tcp_nodelay:2; /* ngx_connection_tcp_nodelay_e */
167 unsigned tcp_nopush:2; /* ngx_connection_tcp_nopush_e */
169 #if (NGX_HAVE_IOCP)
170 unsigned accept_context_updated:1;
171 #endif
173 #if (NGX_HAVE_AIO_SENDFILE)
174 unsigned aio_sendfile:1;
175 ngx_buf_t *busy_sendfile;
176 #endif
178 #if (NGX_THREADS)
179 ngx_atomic_t lock;
180 #endif
184 ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr,
185 socklen_t socklen);
186 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle);
187 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle);
188 void ngx_configure_listening_sockets(ngx_cycle_t *cycle);
189 void ngx_close_listening_sockets(ngx_cycle_t *cycle);
190 void ngx_close_connection(ngx_connection_t *c);
191 ngx_int_t ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
192 ngx_uint_t port);
193 ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text);
195 ngx_connection_t *ngx_get_connection(ngx_socket_t s, ngx_log_t *log);
196 void ngx_free_connection(ngx_connection_t *c);
198 void ngx_reusable_connection(ngx_connection_t *c, ngx_uint_t reusable);
200 #endif /* _NGX_CONNECTION_H_INCLUDED_ */