Mercurial > hg > nginx-quic
annotate src/event/ngx_event_accept.c @ 6227:bd55d75a1410
Fixed wrong URI after try_files in nested location (ticket #97).
The following configuration with alias, nested location and try_files
resulted in wrong file being used. Request "/foo/test.gif" tried to
use "/tmp//foo/test.gif" instead of "/tmp/test.gif":
location /foo/ {
alias /tmp/;
location ~ gif {
try_files $uri =405;
}
}
Additionally, rev. c985d90a8d1f introduced a regression if
the "/tmp//foo/test.gif" file was found (ticket #768). Resulting URI
was set to "gif?/foo/test.gif", as the code used clcf->name of current
location ("location ~ gif") instead of parent one ("location /foo/").
Fix is to use r->uri instead of clcf->name in all cases in the
ngx_http_core_try_files_phase() function. It is expected to be
already matched and identical to the clcf->name of the right
location.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 16 Aug 2015 10:51:34 +0300 |
parents | 4f6efabcb09b |
children | 8f038068f4bc |
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:
431
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:
431
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 |
4412 | 4 * Copyright (C) Nginx, Inc. |
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:
431
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
431
diff
changeset
|
6 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
7 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
8 #include <ngx_config.h> |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
9 #include <ngx_core.h> |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
10 #include <ngx_event.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
573 | 13 static ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle); |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
14 static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle, ngx_uint_t all); |
543 | 15 static void ngx_close_accepted_connection(ngx_connection_t *c); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
16 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
17 |
493 | 18 void |
19 ngx_event_accept(ngx_event_t *ev) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 { |
714 | 21 socklen_t socklen; |
483 | 22 ngx_err_t err; |
23 ngx_log_t *log; | |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
24 ngx_uint_t level; |
483 | 25 ngx_socket_t s; |
26 ngx_event_t *rev, *wev; | |
543 | 27 ngx_listening_t *ls; |
28 ngx_connection_t *c, *lc; | |
483 | 29 ngx_event_conf_t *ecf; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
30 u_char sa[NGX_SOCKADDRLEN]; |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
31 #if (NGX_HAVE_ACCEPT4) |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
32 static ngx_uint_t use_accept4 = 1; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
33 #endif |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
34 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
35 if (ev->timedout) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
36 if (ngx_enable_accept_events((ngx_cycle_t *) ngx_cycle) != NGX_OK) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
37 return; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
38 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
39 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
40 ev->timedout = 0; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
41 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
42 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
43 ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
44 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
45 if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) { |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
46 ev->available = ecf->multi_accept; |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
47 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
48 |
543 | 49 lc = ev->data; |
50 ls = lc->listening; | |
51 ev->ready = 0; | |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
52 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
53 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
543 | 54 "accept on %V, ready: %d", &ls->addr_text, ev->available); |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
55 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 do { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
57 socklen = NGX_SOCKADDRLEN; |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
58 |
3786 | 59 #if (NGX_HAVE_ACCEPT4) |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
60 if (use_accept4) { |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
61 s = accept4(lc->fd, (struct sockaddr *) sa, &socklen, |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
62 SOCK_NONBLOCK); |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
63 } else { |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
64 s = accept(lc->fd, (struct sockaddr *) sa, &socklen); |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
65 } |
3786 | 66 #else |
714 | 67 s = accept(lc->fd, (struct sockaddr *) sa, &socklen); |
3786 | 68 #endif |
477 | 69 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5359
diff
changeset
|
70 if (s == (ngx_socket_t) -1) { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 err = ngx_socket_errno; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
72 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 if (err == NGX_EAGAIN) { |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
74 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, err, |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
75 "accept() not ready"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
76 return; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
78 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
79 level = NGX_LOG_ALERT; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
80 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
81 if (err == NGX_ECONNABORTED) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
82 level = NGX_LOG_ERR; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
83 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
84 } else if (err == NGX_EMFILE || err == NGX_ENFILE) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
85 level = NGX_LOG_CRIT; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
86 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
87 |
3813
c870fb78550c
fix building by msvc8 introduced by the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
3812
diff
changeset
|
88 #if (NGX_HAVE_ACCEPT4) |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
89 ngx_log_error(level, ev->log, err, |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
90 use_accept4 ? "accept4() failed" : "accept() failed"); |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
91 |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
92 if (use_accept4 && err == NGX_ENOSYS) { |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
93 use_accept4 = 0; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
94 ngx_inherited_nonblocking = 0; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
95 continue; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
96 } |
3813
c870fb78550c
fix building by msvc8 introduced by the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
3812
diff
changeset
|
97 #else |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
98 ngx_log_error(level, ev->log, err, "accept() failed"); |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
99 #endif |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
100 |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
101 if (err == NGX_ECONNABORTED) { |
455 | 102 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
103 ev->available--; |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
104 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
105 |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
106 if (ev->available) { |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
107 continue; |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
108 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
109 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
110 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
111 if (err == NGX_EMFILE || err == NGX_ENFILE) { |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
112 if (ngx_disable_accept_events((ngx_cycle_t *) ngx_cycle, 1) |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
113 != NGX_OK) |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
114 { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
115 return; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
116 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
117 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
118 if (ngx_use_accept_mutex) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
119 if (ngx_accept_mutex_held) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
120 ngx_shmtx_unlock(&ngx_accept_mutex); |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
121 ngx_accept_mutex_held = 0; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
122 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
123 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
124 ngx_accept_disabled = 1; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
125 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
126 } else { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
127 ngx_add_timer(ev, ecf->accept_mutex_delay); |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
128 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
129 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
130 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
131 return; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
132 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
133 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
425
diff
changeset
|
134 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
135 (void) ngx_atomic_fetch_add(ngx_stat_accepted, 1); |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
425
diff
changeset
|
136 #endif |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
137 |
2255 | 138 ngx_accept_disabled = ngx_cycle->connection_n / 8 |
543 | 139 - ngx_cycle->free_connection_n; |
140 | |
141 c = ngx_get_connection(s, ev->log); | |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
142 |
543 | 143 if (c == NULL) { |
144 if (ngx_close_socket(s) == -1) { | |
145 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, | |
146 ngx_close_socket_n " failed"); | |
147 } | |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
117
diff
changeset
|
148 |
543 | 149 return; |
150 } | |
151 | |
635 | 152 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
153 (void) ngx_atomic_fetch_add(ngx_stat_active, 1); |
635 | 154 #endif |
155 | |
543 | 156 c->pool = ngx_create_pool(ls->pool_size, ev->log); |
157 if (c->pool == NULL) { | |
158 ngx_close_accepted_connection(c); | |
159 return; | |
160 } | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
161 |
714 | 162 c->sockaddr = ngx_palloc(c->pool, socklen); |
543 | 163 if (c->sockaddr == NULL) { |
164 ngx_close_accepted_connection(c); | |
165 return; | |
166 } | |
167 | |
714 | 168 ngx_memcpy(c->sockaddr, sa, socklen); |
543 | 169 |
170 log = ngx_palloc(c->pool, sizeof(ngx_log_t)); | |
171 if (log == NULL) { | |
172 ngx_close_accepted_connection(c); | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
173 return; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
175 |
6125
4dc8e7b62216
Removed the obsolete aio module.
Ruslan Ermilov <ru@nginx.com>
parents:
5820
diff
changeset
|
176 /* set a blocking mode for iocp and non-blocking mode for others */ |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
177 |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
178 if (ngx_inherited_nonblocking) { |
6125
4dc8e7b62216
Removed the obsolete aio module.
Ruslan Ermilov <ru@nginx.com>
parents:
5820
diff
changeset
|
179 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
180 if (ngx_blocking(s) == -1) { |
543 | 181 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
182 ngx_blocking_n " failed"); |
543 | 183 ngx_close_accepted_connection(c); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
184 return; |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
185 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
186 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
187 |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
188 } else { |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
189 if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) { |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
190 if (ngx_nonblocking(s) == -1) { |
543 | 191 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
192 ngx_nonblocking_n " failed"); |
543 | 193 ngx_close_accepted_connection(c); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
194 return; |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
195 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
196 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
197 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
198 |
543 | 199 *log = ls->log; |
200 | |
201 c->recv = ngx_recv; | |
202 c->send = ngx_send; | |
577 | 203 c->recv_chain = ngx_recv_chain; |
543 | 204 c->send_chain = ngx_send_chain; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
205 |
543 | 206 c->log = log; |
207 c->pool->log = log; | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
208 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
209 c->socklen = socklen; |
543 | 210 c->listening = ls; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
211 c->local_sockaddr = ls->sockaddr; |
5463
1ab1cf63f885
Core: keep the length of the local sockaddr.
Ruslan Ermilov <ru@nginx.com>
parents:
5360
diff
changeset
|
212 c->local_socklen = ls->socklen; |
543 | 213 |
214 c->unexpected_eof = 1; | |
215 | |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
216 #if (NGX_HAVE_UNIX_DOMAIN) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
217 if (c->sockaddr->sa_family == AF_UNIX) { |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
218 c->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
219 c->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
220 #if (NGX_SOLARIS) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
221 /* Solaris's sendfilev() supports AF_NCA, AF_INET, and AF_INET6 */ |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
222 c->sendfile = 0; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
223 #endif |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
224 } |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
225 #endif |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
226 |
561 | 227 rev = c->read; |
228 wev = c->write; | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
229 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
230 wev->ready = 1; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
232 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
233 rev->ready = 1; |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
234 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
235 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
236 if (ev->deferred_accept) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
237 rev->ready = 1; |
523 | 238 #if (NGX_HAVE_KQUEUE) |
239 rev->available = 1; | |
240 #endif | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
241 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
242 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
243 rev->log = log; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
244 wev->log = log; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
245 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
246 /* |
561 | 247 * TODO: MT: - ngx_atomic_fetch_add() |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
248 * or protection by critical section or light mutex |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
249 * |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
250 * TODO: MP: - allocated in a shared memory |
561 | 251 * - ngx_atomic_fetch_add() |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
252 * or protection by critical section or light mutex |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
253 */ |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
254 |
561 | 255 c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
256 |
495 | 257 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
258 (void) ngx_atomic_fetch_add(ngx_stat_handled, 1); |
495 | 259 #endif |
260 | |
543 | 261 if (ls->addr_ntop) { |
2049 | 262 c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len); |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
263 if (c->addr_text.data == NULL) { |
543 | 264 ngx_close_accepted_connection(c); |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
265 return; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
266 } |
577 | 267 |
5263
05ba5bce31e0
Core: extended ngx_sock_ntop() with socklen parameter.
Vladimir Homutov <vl@nginx.com>
parents:
4618
diff
changeset
|
268 c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen, |
05ba5bce31e0
Core: extended ngx_sock_ntop() with socklen parameter.
Vladimir Homutov <vl@nginx.com>
parents:
4618
diff
changeset
|
269 c->addr_text.data, |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
270 ls->addr_text_max_len, 0); |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
271 if (c->addr_text.len == 0) { |
543 | 272 ngx_close_accepted_connection(c); |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
273 return; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
274 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
275 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
276 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
277 #if (NGX_DEBUG) |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
278 { |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
279 |
5704
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
280 ngx_str_t addr; |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
281 struct sockaddr_in *sin; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
282 ngx_cidr_t *cidr; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
283 ngx_uint_t i; |
5704
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
284 u_char text[NGX_SOCKADDR_STRLEN]; |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
285 #if (NGX_HAVE_INET6) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
286 struct sockaddr_in6 *sin6; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
287 ngx_uint_t n; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
288 #endif |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
289 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
290 cidr = ecf->debug_connection.elts; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
291 for (i = 0; i < ecf->debug_connection.nelts; i++) { |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5263
diff
changeset
|
292 if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) { |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
293 goto next; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
294 } |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
295 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
296 switch (cidr[i].family) { |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
297 |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
298 #if (NGX_HAVE_INET6) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
299 case AF_INET6: |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
300 sin6 = (struct sockaddr_in6 *) c->sockaddr; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
301 for (n = 0; n < 16; n++) { |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
302 if ((sin6->sin6_addr.s6_addr[n] |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
303 & cidr[i].u.in6.mask.s6_addr[n]) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
304 != cidr[i].u.in6.addr.s6_addr[n]) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
305 { |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
306 goto next; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
307 } |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
308 } |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
309 break; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
310 #endif |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
311 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
312 #if (NGX_HAVE_UNIX_DOMAIN) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
313 case AF_UNIX: |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
314 break; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
315 #endif |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
316 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
317 default: /* AF_INET */ |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
318 sin = (struct sockaddr_in *) c->sockaddr; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
319 if ((sin->sin_addr.s_addr & cidr[i].u.in.mask) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
320 != cidr[i].u.in.addr) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
321 { |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
322 goto next; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
323 } |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
324 break; |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
325 } |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
326 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
327 log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
328 break; |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
329 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
330 next: |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
331 continue; |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
332 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
333 |
5704
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
334 if (log->log_level & NGX_LOG_DEBUG_EVENT) { |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
335 addr.data = text; |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
336 addr.len = ngx_sock_ntop(c->sockaddr, c->socklen, text, |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
337 NGX_SOCKADDR_STRLEN, 1); |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
338 |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
339 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0, |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
340 "*%uA accept: %V fd:%d", c->number, &addr, s); |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
341 } |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
342 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
343 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
344 #endif |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
345 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
346 if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) { |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
347 if (ngx_add_conn(c) == NGX_ERROR) { |
543 | 348 ngx_close_accepted_connection(c); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
349 return; |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
350 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
351 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
352 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
353 log->data = NULL; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
354 log->handler = NULL; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
355 |
543 | 356 ls->handler(c); |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
357 |
455 | 358 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
359 ev->available--; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
360 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
361 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
362 } while (ev->available); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
363 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
364 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
365 |
493 | 366 ngx_int_t |
367 ngx_trylock_accept_mutex(ngx_cycle_t *cycle) | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
368 { |
611 | 369 if (ngx_shmtx_trylock(&ngx_accept_mutex)) { |
370 | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
371 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
372 "accept mutex locked"); |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
373 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
374 if (ngx_accept_mutex_held && ngx_accept_events == 0) { |
573 | 375 return NGX_OK; |
376 } | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
377 |
573 | 378 if (ngx_enable_accept_events(cycle) == NGX_ERROR) { |
611 | 379 ngx_shmtx_unlock(&ngx_accept_mutex); |
573 | 380 return NGX_ERROR; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
381 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
382 |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
383 ngx_accept_events = 0; |
573 | 384 ngx_accept_mutex_held = 1; |
385 | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
386 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
387 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
388 |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
389 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
390 "accept mutex lock failed: %ui", ngx_accept_mutex_held); |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
391 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
392 if (ngx_accept_mutex_held) { |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
393 if (ngx_disable_accept_events(cycle, 0) == NGX_ERROR) { |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
394 return NGX_ERROR; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
395 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
396 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
397 ngx_accept_mutex_held = 0; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
398 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
399 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
400 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
401 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
402 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
403 |
573 | 404 static ngx_int_t |
493 | 405 ngx_enable_accept_events(ngx_cycle_t *cycle) |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
406 { |
543 | 407 ngx_uint_t i; |
408 ngx_listening_t *ls; | |
409 ngx_connection_t *c; | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
410 |
543 | 411 ls = cycle->listening.elts; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
412 for (i = 0; i < cycle->listening.nelts; i++) { |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
413 |
543 | 414 c = ls[i].connection; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
415 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
416 if (c == NULL || c->read->active) { |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
417 continue; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
418 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
419 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
420 if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) { |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
421 return NGX_ERROR; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
422 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
423 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
424 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
425 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
426 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
427 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
428 |
573 | 429 static ngx_int_t |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
430 ngx_disable_accept_events(ngx_cycle_t *cycle, ngx_uint_t all) |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
431 { |
543 | 432 ngx_uint_t i; |
433 ngx_listening_t *ls; | |
434 ngx_connection_t *c; | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
435 |
543 | 436 ls = cycle->listening.elts; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
437 for (i = 0; i < cycle->listening.nelts; i++) { |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
438 |
543 | 439 c = ls[i].connection; |
440 | |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
441 if (c == NULL || !c->read->active) { |
543 | 442 continue; |
443 } | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
444 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
445 #if (NGX_HAVE_REUSEPORT) |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
446 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
447 /* |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
448 * do not disable accept on worker's own sockets |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
449 * when disabling accept events due to accept mutex |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
450 */ |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
451 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
452 if (ls[i].reuseport && !all) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
453 continue; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
454 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
455 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
456 #endif |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
457 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
458 if (ngx_del_event(c->read, NGX_READ_EVENT, NGX_DISABLE_EVENT) |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
459 == NGX_ERROR) |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
460 { |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
461 return NGX_ERROR; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
462 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
463 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
464 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
465 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
466 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
467 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
468 |
493 | 469 static void |
543 | 470 ngx_close_accepted_connection(ngx_connection_t *c) |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
471 { |
543 | 472 ngx_socket_t fd; |
473 | |
474 ngx_free_connection(c); | |
475 | |
476 fd = c->fd; | |
477 c->fd = (ngx_socket_t) -1; | |
478 | |
479 if (ngx_close_socket(fd) == -1) { | |
480 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno, | |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
481 ngx_close_socket_n " failed"); |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
482 } |
495 | 483 |
543 | 484 if (c->pool) { |
485 ngx_destroy_pool(c->pool); | |
486 } | |
487 | |
495 | 488 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
489 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); |
495 | 490 #endif |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
491 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
492 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
493 |
543 | 494 u_char * |
493 | 495 ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len) |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
496 { |
543 | 497 return ngx_snprintf(buf, len, " while accepting new connection on %V", |
498 log->data); | |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
499 } |