Mercurial > hg > nginx-quic
annotate src/core/ngx_connection.c @ 3429:9ecd253fcc90 stable-0.7
merge r3148, r3152, r3161:
error processing fixes:
*) fail if file size was changed
*) low default connection errors level from alert to error
*) low ENAMETOOLONG logging level
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 01 Feb 2010 14:31:26 +0000 |
parents | 87da6664fb49 |
children | a7491af45540 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
12 ngx_os_io_t ngx_io; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
2806 | 15 ngx_listening_t * |
16 ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen) | |
17 { | |
18 ngx_listening_t *ls; | |
19 struct sockaddr *sa; | |
20 u_char text[NGX_SOCKADDR_STRLEN]; | |
21 | |
22 ls = ngx_array_push(&cf->cycle->listening); | |
23 if (ls == NULL) { | |
24 return NULL; | |
25 } | |
26 | |
27 ngx_memzero(ls, sizeof(ngx_listening_t)); | |
28 | |
29 sa = ngx_palloc(cf->pool, socklen); | |
30 if (sa == NULL) { | |
31 return NULL; | |
32 } | |
33 | |
34 ngx_memcpy(sa, sockaddr, socklen); | |
35 | |
36 ls->sockaddr = sa; | |
37 ls->socklen = socklen; | |
38 | |
39 ls->addr_text.len = ngx_sock_ntop(sa, text, NGX_SOCKADDR_STRLEN, 1); | |
40 | |
41 ls->addr_text.data = ngx_pnalloc(cf->pool, ls->addr_text.len); | |
42 if (ls->addr_text.data == NULL) { | |
43 return NULL; | |
44 } | |
45 | |
46 ngx_memcpy(ls->addr_text.data, text, ls->addr_text.len); | |
47 | |
48 ls->fd = (ngx_socket_t) -1; | |
49 ls->type = SOCK_STREAM; | |
50 | |
51 switch (ls->sockaddr->sa_family) { | |
52 #if (NGX_HAVE_INET6) | |
53 case AF_INET6: | |
54 ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN; | |
55 break; | |
56 #endif | |
57 case AF_INET: | |
58 ls->addr_text_max_len = NGX_INET_ADDRSTRLEN; | |
59 break; | |
60 default: | |
61 ls->addr_text_max_len = NGX_SOCKADDR_STRLEN; | |
62 break; | |
63 } | |
64 | |
65 ls->backlog = NGX_LISTEN_BACKLOG; | |
66 ls->rcvbuf = -1; | |
67 ls->sndbuf = -1; | |
68 | |
69 return ls; | |
70 } | |
71 | |
72 | |
521 | 73 ngx_int_t |
74 ngx_set_inherited_sockets(ngx_cycle_t *cycle) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 { |
523 | 76 size_t len; |
77 ngx_uint_t i; | |
78 ngx_listening_t *ls; | |
563 | 79 socklen_t olen; |
523 | 80 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) |
541 | 81 ngx_err_t err; |
523 | 82 struct accept_filter_arg af; |
83 #endif | |
84 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
85 int timeout; | |
86 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
88 ls = cycle->listening.elts; |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
89 for (i = 0; i < cycle->listening.nelts; i++) { |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
90 |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
91 /* AF_INET only */ |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
92 |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
93 ls[i].sockaddr = ngx_palloc(cycle->pool, sizeof(struct sockaddr_in)); |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
94 if (ls[i].sockaddr == NULL) { |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
95 return NGX_ERROR; |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
96 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
97 |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
98 ls[i].socklen = sizeof(struct sockaddr_in); |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
99 if (getsockname(ls[i].fd, ls[i].sockaddr, &ls[i].socklen) == -1) { |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
100 ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno, |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
101 "getsockname() of the inherited " |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
102 "socket #%d failed", ls[i].fd); |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
103 ls[i].ignore = 1; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
107 switch (ls[i].sockaddr->sa_family) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
109 #if (NGX_HAVE_INET6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
110 case AF_INET6: |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
111 ls[i].addr_text_max_len = NGX_INET6_ADDRSTRLEN; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
112 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
113 #endif |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
114 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
115 case AF_INET: |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
116 ls[i].addr_text_max_len = NGX_INET_ADDRSTRLEN; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
117 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
118 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
119 default: |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
120 ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno, |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
121 "the inherited socket #%d has " |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
122 "an unsupported protocol family", ls[i].fd); |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
123 ls[i].ignore = 1; |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
124 continue; |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
125 } |
461 | 126 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
127 len = ls[i].addr_text_max_len + sizeof(":65535") - 1; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
129 ls[i].addr_text.data = ngx_pnalloc(cycle->pool, len); |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
130 if (ls[i].addr_text.data == NULL) { |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
131 return NGX_ERROR; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
134 len = ngx_sock_ntop(ls[i].sockaddr, ls[i].addr_text.data, len, 1); |
461 | 135 if (len == 0) { |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
136 return NGX_ERROR; |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
137 } |
461 | 138 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2254
diff
changeset
|
139 ls[i].addr_text.len = len; |
523 | 140 |
1377
0d57c150115b
set default listen() backlog to 511 on all platforms except FreeBSD
Igor Sysoev <igor@sysoev.ru>
parents:
1225
diff
changeset
|
141 ls[i].backlog = NGX_LISTEN_BACKLOG; |
537 | 142 |
563 | 143 olen = sizeof(int); |
144 | |
145 if (getsockopt(ls[i].fd, SOL_SOCKET, SO_RCVBUF, (void *) &ls[i].rcvbuf, | |
146 &olen) | |
147 == -1) | |
148 { | |
149 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
150 "getsockopt(SO_RCVBUF) %V failed, ignored", | |
151 &ls[i].addr_text); | |
152 | |
153 ls[i].rcvbuf = -1; | |
154 } | |
155 | |
156 olen = sizeof(int); | |
157 | |
158 if (getsockopt(ls[i].fd, SOL_SOCKET, SO_SNDBUF, (void *) &ls[i].sndbuf, | |
159 &olen) | |
160 == -1) | |
161 { | |
162 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
163 "getsockopt(SO_SNDBUF) %V failed, ignored", | |
164 &ls[i].addr_text); | |
165 | |
166 ls[i].sndbuf = -1; | |
167 } | |
168 | |
523 | 169 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) |
170 | |
171 ngx_memzero(&af, sizeof(struct accept_filter_arg)); | |
563 | 172 olen = sizeof(struct accept_filter_arg); |
523 | 173 |
563 | 174 if (getsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, &af, &olen) |
523 | 175 == -1) |
176 { | |
541 | 177 err = ngx_errno; |
178 | |
179 if (err == NGX_EINVAL) { | |
180 continue; | |
181 } | |
182 | |
183 ngx_log_error(NGX_LOG_NOTICE, cycle->log, err, | |
523 | 184 "getsockopt(SO_ACCEPTFILTER) for %V failed, ignored", |
185 &ls[i].addr_text); | |
186 continue; | |
187 } | |
188 | |
563 | 189 if (olen < sizeof(struct accept_filter_arg) || af.af_name[0] == '\0') { |
523 | 190 continue; |
191 } | |
192 | |
193 ls[i].accept_filter = ngx_palloc(cycle->pool, 16); | |
194 if (ls[i].accept_filter == NULL) { | |
195 return NGX_ERROR; | |
196 } | |
197 | |
198 (void) ngx_cpystrn((u_char *) ls[i].accept_filter, | |
199 (u_char *) af.af_name, 16); | |
200 #endif | |
201 | |
202 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
203 | |
204 timeout = 0; | |
563 | 205 olen = sizeof(int); |
523 | 206 |
563 | 207 if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, &olen) |
523 | 208 == -1) |
209 { | |
210 ngx_log_error(NGX_LOG_NOTICE, cycle->log, ngx_errno, | |
211 "getsockopt(TCP_DEFER_ACCEPT) for %V failed, ignored", | |
212 &ls[i].addr_text); | |
213 continue; | |
214 } | |
215 | |
565 | 216 if (olen < sizeof(int) || timeout == 0) { |
523 | 217 continue; |
218 } | |
219 | |
220 ls[i].deferred_accept = 1; | |
221 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 return NGX_OK; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
521 | 228 ngx_int_t |
229 ngx_open_listening_sockets(ngx_cycle_t *cycle) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 { |
563 | 231 int reuseaddr; |
232 ngx_uint_t i, tries, failed; | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
233 ngx_err_t err; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
234 ngx_log_t *log; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
235 ngx_socket_t s; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
236 ngx_listening_t *ls; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 reuseaddr = 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 #if (NGX_SUPPRESS_WARN) |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 failed = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 #endif |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
243 log = cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 |
563 | 245 /* TODO: configurable try number */ |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 |
2024 | 247 for (tries = 5; tries; tries--) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 failed = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 /* for each listening socket */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 ls = cycle->listening.elts; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 for (i = 0; i < cycle->listening.nelts; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 if (ls[i].ignore) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 if (ls[i].fd != -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 if (ls[i].inherited) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 /* TODO: close on exit */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 /* TODO: nonblocking */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 /* TODO: deferred accept */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
269 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
270 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 |
2198
5975975eedc0
ngx_sock_ntop() takes family from sockaddr, remove duplicate field
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
272 s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 if (s == -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
461 | 276 ngx_socket_n " %V failed", &ls[i].addr_text); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 return NGX_ERROR; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
280 if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, |
563 | 281 (const void *) &reuseaddr, sizeof(int)) |
282 == -1) | |
283 { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
461 | 285 "setsockopt(SO_REUSEADDR) %V failed", |
286 &ls[i].addr_text); | |
563 | 287 |
1223 | 288 if (ngx_close_socket(s) == -1) { |
563 | 289 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
290 ngx_close_socket_n " %V failed", | |
291 &ls[i].addr_text); | |
1223 | 292 } |
563 | 293 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 return NGX_ERROR; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
296 |
2562 | 297 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) |
298 | |
299 if (ls[i].sockaddr->sa_family == AF_INET6 && ls[i].ipv6only) { | |
300 int ipv6only; | |
301 | |
302 ipv6only = (ls[i].ipv6only == 1); | |
303 | |
304 if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, | |
305 (const void *) &ipv6only, sizeof(int)) | |
306 == -1) | |
307 { | |
2801 | 308 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
2562 | 309 "setsockopt(IPV6_V6ONLY) %V failed, ignored", |
310 &ls[i].addr_text); | |
311 } | |
312 } | |
313 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 /* TODO: close on exit */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 if (!(ngx_event_flags & NGX_USE_AIO_EVENT)) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 if (ngx_nonblocking(s) == -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
461 | 319 ngx_nonblocking_n " %V failed", |
320 &ls[i].addr_text); | |
563 | 321 |
1223 | 322 if (ngx_close_socket(s) == -1) { |
563 | 323 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
324 ngx_close_socket_n " %V failed", | |
325 &ls[i].addr_text); | |
1223 | 326 } |
563 | 327 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
328 return NGX_ERROR; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
329 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
330 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
331 |
2801 | 332 ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0, |
593 | 333 "bind() %V #%d ", &ls[i].addr_text, s); |
334 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 if (bind(s, ls[i].sockaddr, ls[i].socklen) == -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
336 err = ngx_socket_errno; |
563 | 337 |
338 if (err == NGX_EADDRINUSE && ngx_test_config) { | |
339 continue; | |
340 } | |
341 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
342 ngx_log_error(NGX_LOG_EMERG, log, err, |
461 | 343 "bind() to %V failed", &ls[i].addr_text); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
344 |
1223 | 345 if (ngx_close_socket(s) == -1) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
346 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
461 | 347 ngx_close_socket_n " %V failed", |
348 &ls[i].addr_text); | |
1223 | 349 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
350 |
563 | 351 if (err != NGX_EADDRINUSE) { |
352 return NGX_ERROR; | |
353 } | |
354 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
355 failed = 1; |
563 | 356 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
357 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
359 |
1224
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
360 if (listen(s, ls[i].backlog) == -1) { |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
361 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
362 "listen() to %V, backlog %d failed", |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
363 &ls[i].addr_text, ls[i].backlog); |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
364 |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
365 if (ngx_close_socket(s) == -1) { |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
366 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
367 ngx_close_socket_n " %V failed", |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
368 &ls[i].addr_text); |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
369 } |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
370 |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
371 return NGX_ERROR; |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
372 } |
53e3dd035140
do listen() just after bind() to exit early
Igor Sysoev <igor@sysoev.ru>
parents:
1223
diff
changeset
|
373 |
563 | 374 ls[i].listen = 1; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
375 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
376 ls[i].fd = s; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
377 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
378 |
563 | 379 if (!failed) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
380 break; |
563 | 381 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
382 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
383 /* TODO: delay configurable */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
384 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
385 ngx_log_error(NGX_LOG_NOTICE, log, 0, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
386 "try again to bind() after 500ms"); |
563 | 387 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
388 ngx_msleep(500); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
389 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
390 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
391 if (failed) { |
477 | 392 ngx_log_error(NGX_LOG_EMERG, log, 0, "still could not bind()"); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
393 return NGX_ERROR; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
394 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
395 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
396 return NGX_OK; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
397 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
398 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
399 |
521 | 400 void |
2802 | 401 ngx_configure_listening_sockets(ngx_cycle_t *cycle) |
563 | 402 { |
403 ngx_uint_t i; | |
404 ngx_listening_t *ls; | |
405 | |
406 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
407 struct accept_filter_arg af; | |
408 #endif | |
409 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
410 int timeout; | |
411 #endif | |
412 | |
413 ls = cycle->listening.elts; | |
414 for (i = 0; i < cycle->listening.nelts; i++) { | |
415 | |
2803
60758ab4e5f4
move listen log copying from ngx_open_listening_sockets()
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
416 ls[i].log = *ls[i].logp; |
60758ab4e5f4
move listen log copying from ngx_open_listening_sockets()
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
417 |
563 | 418 if (ls[i].rcvbuf != -1) { |
419 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_RCVBUF, | |
420 (const void *) &ls[i].rcvbuf, sizeof(int)) | |
421 == -1) | |
422 { | |
423 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
569 | 424 "setsockopt(SO_RCVBUF, %d) %V failed, ignored", |
425 ls[i].rcvbuf, &ls[i].addr_text); | |
563 | 426 } |
427 } | |
428 | |
429 if (ls[i].sndbuf != -1) { | |
430 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_SNDBUF, | |
431 (const void *) &ls[i].sndbuf, sizeof(int)) | |
432 == -1) | |
433 { | |
434 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
569 | 435 "setsockopt(SO_SNDBUF, %d) %V failed, ignored", |
436 ls[i].sndbuf, &ls[i].addr_text); | |
563 | 437 } |
438 } | |
439 | |
635 | 440 #if 0 |
441 if (1) { | |
442 int tcp_nodelay = 1; | |
443 | |
444 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_NODELAY, | |
445 (const void *) &tcp_nodelay, sizeof(int)) | |
446 == -1) | |
447 { | |
448 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
449 "setsockopt(TCP_NODELAY) %V failed, ignored", | |
450 &ls[i].addr_text); | |
451 } | |
452 } | |
453 #endif | |
454 | |
563 | 455 if (ls[i].listen) { |
1225 | 456 |
457 /* change backlog via listen() */ | |
458 | |
563 | 459 if (listen(ls[i].fd, ls[i].backlog) == -1) { |
460 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, | |
1222 | 461 "listen() to %V, backlog %d failed, ignored", |
462 &ls[i].addr_text, ls[i].backlog); | |
563 | 463 } |
464 } | |
465 | |
466 /* | |
467 * setting deferred mode should be last operation on socket, | |
468 * because code may prematurely continue cycle on failure | |
469 */ | |
470 | |
471 #if (NGX_HAVE_DEFERRED_ACCEPT) | |
472 | |
473 #ifdef SO_ACCEPTFILTER | |
474 | |
627 | 475 if (ls[i].delete_deferred) { |
476 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0) | |
477 == -1) | |
563 | 478 { |
479 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
480 "setsockopt(SO_ACCEPTFILTER, NULL) " | |
481 "for %V failed, ignored", | |
627 | 482 &ls[i].addr_text); |
563 | 483 |
627 | 484 if (ls[i].accept_filter) { |
563 | 485 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
486 "could not change the accept filter " | |
487 "to \"%s\" for %V, ignored", | |
627 | 488 ls[i].accept_filter, &ls[i].addr_text); |
563 | 489 } |
490 | |
491 continue; | |
492 } | |
493 | |
627 | 494 ls[i].deferred_accept = 0; |
563 | 495 } |
496 | |
627 | 497 if (ls[i].add_deferred) { |
563 | 498 ngx_memzero(&af, sizeof(struct accept_filter_arg)); |
499 (void) ngx_cpystrn((u_char *) af.af_name, | |
627 | 500 (u_char *) ls[i].accept_filter, 16); |
563 | 501 |
627 | 502 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, |
563 | 503 &af, sizeof(struct accept_filter_arg)) |
504 == -1) | |
505 { | |
506 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
507 "setsockopt(SO_ACCEPTFILTER, \"%s\") " | |
508 " for %V failed, ignored", | |
627 | 509 ls[i].accept_filter, &ls[i].addr_text); |
563 | 510 continue; |
511 } | |
512 | |
627 | 513 ls[i].deferred_accept = 1; |
563 | 514 } |
515 | |
516 #endif | |
517 | |
518 #ifdef TCP_DEFER_ACCEPT | |
519 | |
627 | 520 if (ls[i].add_deferred || ls[i].delete_deferred) { |
563 | 521 |
627 | 522 if (ls[i].add_deferred) { |
523 timeout = (int) (ls[i].post_accept_timeout / 1000); | |
563 | 524 |
525 } else { | |
526 timeout = 0; | |
527 } | |
528 | |
627 | 529 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, |
563 | 530 &timeout, sizeof(int)) |
531 == -1) | |
532 { | |
533 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
534 "setsockopt(TCP_DEFER_ACCEPT, %d) for %V failed, " | |
535 "ignored", | |
627 | 536 timeout, &ls[i].addr_text); |
563 | 537 |
538 continue; | |
539 } | |
540 } | |
541 | |
627 | 542 if (ls[i].add_deferred) { |
543 ls[i].deferred_accept = 1; | |
563 | 544 } |
545 | |
546 #endif | |
547 | |
548 #endif /* NGX_HAVE_DEFERRED_ACCEPT */ | |
549 } | |
550 | |
551 return; | |
552 } | |
553 | |
554 | |
555 void | |
521 | 556 ngx_close_listening_sockets(ngx_cycle_t *cycle) |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
557 { |
543 | 558 ngx_uint_t i; |
559 ngx_listening_t *ls; | |
560 ngx_connection_t *c; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
561 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
562 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
563 return; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
564 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
565 |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
566 ngx_accept_mutex_held = 0; |
611 | 567 ngx_use_accept_mutex = 0; |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
568 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
569 ls = cycle->listening.elts; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
570 for (i = 0; i < cycle->listening.nelts; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
571 |
543 | 572 c = ls[i].connection; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
573 |
2725 | 574 if (c) { |
575 if (c->read->active) { | |
576 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { | |
577 ngx_del_conn(c, NGX_CLOSE_EVENT); | |
1833
86464f8eddd6
workaround for Linux 2.6 OpenVZ
Igor Sysoev <igor@sysoev.ru>
parents:
1435
diff
changeset
|
578 |
2725 | 579 } else if (ngx_event_flags & NGX_USE_EPOLL_EVENT) { |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
303
diff
changeset
|
580 |
2725 | 581 /* |
582 * it seems that Linux-2.6.x OpenVZ sends events | |
583 * for closed shared listening sockets unless | |
584 * the events was explicity deleted | |
585 */ | |
1833
86464f8eddd6
workaround for Linux 2.6 OpenVZ
Igor Sysoev <igor@sysoev.ru>
parents:
1435
diff
changeset
|
586 |
2725 | 587 ngx_del_event(c->read, NGX_READ_EVENT, 0); |
1833
86464f8eddd6
workaround for Linux 2.6 OpenVZ
Igor Sysoev <igor@sysoev.ru>
parents:
1435
diff
changeset
|
588 |
2725 | 589 } else { |
590 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); | |
591 } | |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
303
diff
changeset
|
592 } |
2725 | 593 |
594 ngx_free_connection(c); | |
595 | |
596 c->fd = (ngx_socket_t) -1; | |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
303
diff
changeset
|
597 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
598 |
563 | 599 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
600 "close listening %V #%d ", &ls[i].addr_text, ls[i].fd); | |
601 | |
543 | 602 if (ngx_close_socket(ls[i].fd) == -1) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
603 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, |
461 | 604 ngx_close_socket_n " %V failed", &ls[i].addr_text); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
605 } |
2945
87da6664fb49
merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907,
Igor Sysoev <igor@sysoev.ru>
parents:
2854
diff
changeset
|
606 |
87da6664fb49
merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907,
Igor Sysoev <igor@sysoev.ru>
parents:
2854
diff
changeset
|
607 ls[i].fd = (ngx_socket_t) -1; |
543 | 608 } |
609 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
610 |
543 | 611 |
612 ngx_connection_t * | |
613 ngx_get_connection(ngx_socket_t s, ngx_log_t *log) | |
614 { | |
561 | 615 ngx_uint_t instance; |
616 ngx_event_t *rev, *wev; | |
617 ngx_connection_t *c; | |
543 | 618 |
619 /* disable warning: Win32 SOCKET is u_int while UNIX socket is int */ | |
620 | |
621 if (ngx_cycle->files && (ngx_uint_t) s >= ngx_cycle->files_n) { | |
622 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
623 "the new socket has number %d, " | |
624 "but only %ui files are available", | |
625 s, ngx_cycle->files_n); | |
626 return NULL; | |
627 } | |
628 | |
629 /* ngx_mutex_lock */ | |
630 | |
631 c = ngx_cycle->free_connections; | |
632 | |
633 if (c == NULL) { | |
634 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
2254 | 635 "%ui worker_connections are not enough", |
543 | 636 ngx_cycle->connection_n); |
637 | |
638 /* ngx_mutex_unlock */ | |
639 | |
640 return NULL; | |
641 } | |
642 | |
643 ngx_cycle->free_connections = c->data; | |
644 ngx_cycle->free_connection_n--; | |
645 | |
646 /* ngx_mutex_unlock */ | |
647 | |
648 if (ngx_cycle->files) { | |
649 ngx_cycle->files[s] = c; | |
650 } | |
651 | |
561 | 652 rev = c->read; |
653 wev = c->write; | |
654 | |
655 ngx_memzero(c, sizeof(ngx_connection_t)); | |
656 | |
657 c->read = rev; | |
658 c->write = wev; | |
659 c->fd = s; | |
660 c->log = log; | |
661 | |
662 instance = rev->instance; | |
663 | |
664 ngx_memzero(rev, sizeof(ngx_event_t)); | |
665 ngx_memzero(wev, sizeof(ngx_event_t)); | |
666 | |
667 rev->instance = !instance; | |
668 wev->instance = !instance; | |
669 | |
670 rev->index = NGX_INVALID_INDEX; | |
671 wev->index = NGX_INVALID_INDEX; | |
672 | |
673 rev->data = c; | |
674 wev->data = c; | |
675 | |
676 wev->write = 1; | |
677 | |
543 | 678 return c; |
679 } | |
680 | |
681 | |
682 void | |
683 ngx_free_connection(ngx_connection_t *c) | |
684 { | |
685 /* ngx_mutex_lock */ | |
686 | |
687 c->data = ngx_cycle->free_connections; | |
688 ngx_cycle->free_connections = c; | |
689 ngx_cycle->free_connection_n++; | |
690 | |
691 /* ngx_mutex_unlock */ | |
692 | |
693 if (ngx_cycle->files) { | |
694 ngx_cycle->files[c->fd] = NULL; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
695 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
696 } |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
697 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
698 |
521 | 699 void |
700 ngx_close_connection(ngx_connection_t *c) | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
701 { |
1917
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
702 ngx_err_t err; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
703 ngx_uint_t log_error, level; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
704 ngx_socket_t fd; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
705 |
479 | 706 if (c->fd == -1) { |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
707 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed"); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
708 return; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
709 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
710 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
711 if (c->read->timer_set) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
712 ngx_del_timer(c->read); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
713 } |
577 | 714 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
715 if (c->write->timer_set) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
716 ngx_del_timer(c->write); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
717 } |
577 | 718 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
719 if (ngx_del_conn) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
720 ngx_del_conn(c, NGX_CLOSE_EVENT); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
721 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
722 } else { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
723 if (c->read->active || c->read->disabled) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
724 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
725 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
726 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
727 if (c->write->active || c->write->disabled) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
728 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
729 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
730 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
731 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
732 #if (NGX_THREADS) |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
733 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
734 /* |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
735 * we have to clean the connection information before the closing |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
736 * because another thread may reopen the same file descriptor |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
737 * before we clean the connection |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
738 */ |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
739 |
563 | 740 ngx_mutex_lock(ngx_posted_events_mutex); |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
741 |
563 | 742 if (c->read->prev) { |
743 ngx_delete_posted_event(c->read); | |
744 } | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
745 |
563 | 746 if (c->write->prev) { |
747 ngx_delete_posted_event(c->write); | |
748 } | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
749 |
563 | 750 c->read->closed = 1; |
751 c->write->closed = 1; | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
752 |
563 | 753 if (c->single_connection) { |
754 ngx_unlock(&c->lock); | |
755 c->read->locked = 0; | |
756 c->write->locked = 0; | |
757 } | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
758 |
563 | 759 ngx_mutex_unlock(ngx_posted_events_mutex); |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
760 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
761 #else |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
762 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
763 if (c->read->prev) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
764 ngx_delete_posted_event(c->read); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
765 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
766 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
767 if (c->write->prev) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
768 ngx_delete_posted_event(c->write); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
769 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
770 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
771 c->read->closed = 1; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
772 c->write->closed = 1; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
773 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
774 #endif |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
775 |
1917
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
776 log_error = c->log_error; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
777 |
543 | 778 ngx_free_connection(c); |
779 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
780 fd = c->fd; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
781 c->fd = (ngx_socket_t) -1; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
782 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
783 if (ngx_close_socket(fd) == -1) { |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
784 |
1917
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
785 err = ngx_socket_errno; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
786 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
787 if (err == NGX_ECONNRESET || err == NGX_ENOTCONN) { |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
788 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
789 switch (log_error) { |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
790 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
791 case NGX_ERROR_INFO: |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
792 level = NGX_LOG_INFO; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
793 break; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
794 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
795 case NGX_ERROR_ERR: |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
796 level = NGX_LOG_ERR; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
797 break; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
798 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
799 default: |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
800 level = NGX_LOG_CRIT; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
801 } |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
802 |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
803 } else { |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
804 level = NGX_LOG_CRIT; |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
805 } |
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
806 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
807 /* we use ngx_cycle->log because c->log was in c->pool */ |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
808 |
1917
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
809 ngx_log_error(level, ngx_cycle->log, err, |
1435 | 810 ngx_close_socket_n " %d failed", fd); |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
811 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
812 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
813 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
814 |
521 | 815 ngx_int_t |
2854
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
816 ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s, |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
817 ngx_uint_t port) |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
818 { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
819 socklen_t len; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
820 ngx_uint_t addr; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
821 u_char sa[NGX_SOCKADDRLEN]; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
822 struct sockaddr_in *sin; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
823 #if (NGX_HAVE_INET6) |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
824 ngx_uint_t i; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
825 struct sockaddr_in6 *sin6; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
826 #endif |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
827 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
828 switch (c->local_sockaddr->sa_family) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
829 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
830 #if (NGX_HAVE_INET6) |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
831 case AF_INET6: |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
832 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
833 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
834 for (addr = 0, i = 0; addr == 0 && i < 16; i++) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
835 addr |= sin6->sin6_addr.s6_addr[i]; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
836 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
837 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
838 break; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
839 #endif |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
840 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
841 default: /* AF_INET */ |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
842 sin = (struct sockaddr_in *) c->local_sockaddr; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
843 addr = sin->sin_addr.s_addr; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
844 break; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
845 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
846 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
847 if (addr == 0) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
848 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
849 len = NGX_SOCKADDRLEN; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
850 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
851 if (getsockname(c->fd, (struct sockaddr *) &sa, &len) == -1) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
852 ngx_connection_error(c, ngx_socket_errno, "getsockname() failed"); |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
853 return NGX_ERROR; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
854 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
855 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
856 c->local_sockaddr = ngx_palloc(c->pool, len); |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
857 if (c->local_sockaddr == NULL) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
858 return NGX_ERROR; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
859 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
860 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
861 c->local_socklen = len; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
862 ngx_memcpy(c->local_sockaddr, &sa, len); |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
863 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
864 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
865 if (s == NULL) { |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
866 return NGX_OK; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
867 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
868 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
869 s->len = ngx_sock_ntop(c->local_sockaddr, s->data, s->len, port); |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
870 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
871 return NGX_OK; |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
872 } |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
873 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
874 |
d788477f5a67
ngx_connection_local_sockaddr()
Igor Sysoev <igor@sysoev.ru>
parents:
2806
diff
changeset
|
875 ngx_int_t |
521 | 876 ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text) |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
877 { |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
878 ngx_uint_t level; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
879 |
2775 | 880 /* Winsock may return NGX_ECONNABORTED instead of NGX_ECONNRESET */ |
2774
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
881 |
2775 | 882 if ((err == NGX_ECONNRESET |
883 #if (NGX_WIN32) | |
884 || err == NGX_ECONNABORTED | |
2774
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
885 #endif |
2775 | 886 ) && c->log_error == NGX_ERROR_IGNORE_ECONNRESET) |
2774
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
887 { |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
888 return 0; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
889 } |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
890 |
2560
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
891 #if (NGX_SOLARIS) |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
892 if (err == NGX_EINVAL && c->log_error == NGX_ERROR_IGNORE_EINVAL) { |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
893 return 0; |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
894 } |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
895 #endif |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
896 |
537 | 897 if (err == 0 |
898 || err == NGX_ECONNRESET | |
2774
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
899 #if (NGX_WIN32) |
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
900 || err == NGX_ECONNABORTED |
baad3036086e
Winsock uses ECONNABORTED instead of ECONNRESET
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
901 #else |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
902 || err == NGX_EPIPE |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
903 #endif |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
904 || err == NGX_ENOTCONN |
587 | 905 || err == NGX_ETIMEDOUT |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
906 || err == NGX_ECONNREFUSED |
1869
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1833
diff
changeset
|
907 || err == NGX_ENETDOWN |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1833
diff
changeset
|
908 || err == NGX_ENETUNREACH |
192443881e51
add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN
Igor Sysoev <igor@sysoev.ru>
parents:
1833
diff
changeset
|
909 || err == NGX_EHOSTDOWN |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
910 || err == NGX_EHOSTUNREACH) |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
911 { |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
912 switch (c->log_error) { |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
913 |
2560
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
914 case NGX_ERROR_IGNORE_EINVAL: |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
915 case NGX_ERROR_IGNORE_ECONNRESET: |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
916 case NGX_ERROR_INFO: |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
917 level = NGX_LOG_INFO; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
918 break; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
919 |
3429 | 920 default: |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
921 level = NGX_LOG_ERR; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
922 } |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
923 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
924 } else { |
1917
1b2e83c4886d
decrease log level of connection errors while closing socket
Igor Sysoev <igor@sysoev.ru>
parents:
1869
diff
changeset
|
925 level = NGX_LOG_ALERT; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
926 } |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
927 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
928 ngx_log_error(level, c->log, err, text); |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
929 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
930 return NGX_ERROR; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
931 } |