comparison src/core/ngx_connection.h @ 0:f0b350454894 NGINX_0_1_0

nginx 0.1.0 *) The first public version.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Oct 2004 00:00:00 +0400
parents
children cc9f381affaa
comparison
equal deleted inserted replaced
-1:000000000000 0:f0b350454894
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
15 typedef struct {
16 ngx_socket_t fd;
17
18 struct sockaddr *sockaddr;
19 socklen_t socklen; /* size of sockaddr */
20 int addr; /* offset to address in sockaddr */
21 int addr_text_max_len;
22 ngx_str_t addr_text;
23
24 int family;
25 int type;
26 int protocol;
27 int flags; /* Winsock2 flags */
28
29 void (*handler)(ngx_connection_t *c); /* handler of accepted
30 connection */
31 void *ctx; /* ngx_http_conf_ctx_t, for example */
32 void *servers; /* array of ngx_http_in_addr_t, for example */
33
34 ngx_log_t *log;
35 int backlog;
36
37 size_t pool_size;
38 size_t post_accept_buffer_size; /* should be here because
39 of the AcceptEx() preread */
40 time_t post_accept_timeout; /* should be here because
41 of the deferred accept */
42
43 unsigned new:1;
44 unsigned remain:1;
45 unsigned ignore:1;
46
47 unsigned bound:1; /* already bound */
48 unsigned inherited:1; /* inherited from previous process */
49 unsigned nonblocking_accept:1;
50 unsigned nonblocking:1;
51 #if 0
52 unsigned overlapped:1; /* Winsock2 overlapped */
53 #endif
54 unsigned shared:1; /* shared between threads or processes */
55 #if (HAVE_DEFERRED_ACCEPT)
56 unsigned deferred_accept:1;
57 #endif
58
59 unsigned addr_ntop:1;
60 } ngx_listening_t;
61
62
63 typedef enum {
64 NGX_ERROR_CRIT = 0,
65 NGX_ERROR_ERR,
66 NGX_ERROR_INFO,
67 NGX_ERROR_IGNORE_ECONNRESET
68 } ngx_connection_log_error_e;
69
70
71 typedef enum {
72 NGX_TCP_NOPUSH_DISABLED = -1,
73 NGX_TCP_NOPUSH_UNSET = 0,
74 NGX_TCP_NOPUSH_SET
75 } ngx_connection_tcp_nopush_e;
76
77
78 struct ngx_connection_s {
79 void *data;
80 ngx_event_t *read;
81 ngx_event_t *write;
82
83 ngx_socket_t fd;
84
85 ngx_recv_pt recv;
86 ngx_send_chain_pt send_chain;
87
88 ngx_listening_t *listening;
89
90 off_t sent;
91
92 void *ctx;
93 void *servers;
94
95
96 ngx_log_t *log;
97
98 ngx_pool_t *pool;
99
100 struct sockaddr *sockaddr;
101 socklen_t socklen;
102 ngx_str_t addr_text;
103
104 #if (NGX_OPENSSL)
105 ngx_ssl_t *ssl;
106 #endif
107
108 #if (HAVE_IOCP)
109 struct sockaddr *local_sockaddr;
110 socklen_t local_socklen;
111 #endif
112
113 ngx_buf_t *buffer;
114
115 ngx_uint_t number;
116
117 unsigned log_error:2; /* ngx_connection_log_error_e */
118
119 unsigned buffered:1;
120 unsigned single_connection:1;
121 unsigned unexpected_eof:1;
122 unsigned timedout:1;
123 signed tcp_nopush:2;
124 #if (HAVE_IOCP)
125 unsigned accept_context_updated:1;
126 #endif
127
128 #if (NGX_THREADS)
129 ngx_atomic_t lock;
130 #endif
131 };
132
133
134 #ifndef ngx_ssl_set_nosendshut
135 #define ngx_ssl_set_nosendshut(ssl)
136 #endif
137
138
139 ngx_listening_t *ngx_listening_inet_stream_socket(ngx_conf_t *cf,
140 in_addr_t addr,
141 in_port_t port);
142 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle);
143 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle);
144 void ngx_close_listening_sockets(ngx_cycle_t *cycle);
145 void ngx_close_connection(ngx_connection_t *c);
146 ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text);
147
148
149 extern ngx_os_io_t ngx_io;
150
151
152 #endif /* _NGX_CONNECTION_H_INCLUDED_ */