Mercurial > hg > nginx-quic
annotate src/event/ngx_event_accept.c @ 8848:dde5cb0205ef quic
QUIC: fixed the "quic_stream_buffer_size" directive.
The default value is now correctly set and the configuration
is properly merged.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 08 Feb 2022 23:00:12 +0300 |
parents | e2d07e4ec636 |
children |
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 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
13 static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle, ngx_uint_t all); |
8804
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
14 #if (NGX_HAVE_EPOLLEXCLUSIVE) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
15 static void ngx_reorder_accept_events(ngx_listening_t *ls); |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
16 #endif |
543 | 17 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
|
18 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
19 |
493 | 20 void |
21 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
|
22 { |
714 | 23 socklen_t socklen; |
483 | 24 ngx_err_t err; |
25 ngx_log_t *log; | |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
26 ngx_uint_t level; |
483 | 27 ngx_socket_t s; |
28 ngx_event_t *rev, *wev; | |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
29 ngx_sockaddr_t sa; |
543 | 30 ngx_listening_t *ls; |
31 ngx_connection_t *c, *lc; | |
483 | 32 ngx_event_conf_t *ecf; |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
33 #if (NGX_HAVE_ACCEPT4) |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
34 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
|
35 #endif |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
36 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
37 if (ev->timedout) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
38 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
|
39 return; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
40 } |
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 ev->timedout = 0; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
43 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
44 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
45 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
|
46 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
47 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
|
48 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
|
49 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
50 |
543 | 51 lc = ev->data; |
52 ls = lc->listening; | |
53 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
|
54 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
55 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
543 | 56 "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
|
57 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 do { |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
59 socklen = sizeof(ngx_sockaddr_t); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
60 |
3786 | 61 #if (NGX_HAVE_ACCEPT4) |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
62 if (use_accept4) { |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
63 s = accept4(lc->fd, &sa.sockaddr, &socklen, SOCK_NONBLOCK); |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
64 } else { |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
65 s = accept(lc->fd, &sa.sockaddr, &socklen); |
3812
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
66 } |
3786 | 67 #else |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
68 s = accept(lc->fd, &sa.sockaddr, &socklen); |
3786 | 69 #endif |
477 | 70 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5359
diff
changeset
|
71 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
|
72 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
|
73 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
74 if (err == NGX_EAGAIN) { |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
75 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
|
76 "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
|
77 return; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
79 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
80 level = NGX_LOG_ALERT; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
81 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
82 if (err == NGX_ECONNABORTED) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
83 level = NGX_LOG_ERR; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
84 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
85 } 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
|
86 level = NGX_LOG_CRIT; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
87 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
88 |
3813
c870fb78550c
fix building by msvc8 introduced by the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
3812
diff
changeset
|
89 #if (NGX_HAVE_ACCEPT4) |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
90 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
|
91 use_accept4 ? "accept4() failed" : "accept() failed"); |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
92 |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
93 if (use_accept4 && err == NGX_ENOSYS) { |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
94 use_accept4 = 0; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
95 ngx_inherited_nonblocking = 0; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
96 continue; |
ef27dc1a7832
fallback to accept() if accept4() is not implemented,
Igor Sysoev <igor@sysoev.ru>
parents:
3786
diff
changeset
|
97 } |
3813
c870fb78550c
fix building by msvc8 introduced by the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
3812
diff
changeset
|
98 #else |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
99 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
|
100 #endif |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
101 |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
102 if (err == NGX_ECONNABORTED) { |
455 | 103 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
|
104 ev->available--; |
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 |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
107 if (ev->available) { |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
108 continue; |
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 } |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
111 |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
112 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
|
113 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
|
114 != NGX_OK) |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
115 { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
116 return; |
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 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
119 if (ngx_use_accept_mutex) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
120 if (ngx_accept_mutex_held) { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
121 ngx_shmtx_unlock(&ngx_accept_mutex); |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
122 ngx_accept_mutex_held = 0; |
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 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
125 ngx_accept_disabled = 1; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
126 |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
127 } else { |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
128 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
|
129 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
130 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
131 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
132 return; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
133 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
134 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
425
diff
changeset
|
135 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
136 (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
|
137 #endif |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
138 |
2255 | 139 ngx_accept_disabled = ngx_cycle->connection_n / 8 |
543 | 140 - ngx_cycle->free_connection_n; |
141 | |
142 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
|
143 |
543 | 144 if (c == NULL) { |
145 if (ngx_close_socket(s) == -1) { | |
146 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, | |
147 ngx_close_socket_n " failed"); | |
148 } | |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
117
diff
changeset
|
149 |
543 | 150 return; |
151 } | |
152 | |
6436 | 153 c->type = SOCK_STREAM; |
154 | |
635 | 155 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
156 (void) ngx_atomic_fetch_add(ngx_stat_active, 1); |
635 | 157 #endif |
158 | |
543 | 159 c->pool = ngx_create_pool(ls->pool_size, ev->log); |
160 if (c->pool == NULL) { | |
161 ngx_close_accepted_connection(c); | |
162 return; | |
163 } | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
164 |
7119
fef61d26da39
Fixed buffer overread with unix sockets after accept().
Maxim Dounin <mdounin@mdounin.ru>
parents:
7005
diff
changeset
|
165 if (socklen > (socklen_t) sizeof(ngx_sockaddr_t)) { |
fef61d26da39
Fixed buffer overread with unix sockets after accept().
Maxim Dounin <mdounin@mdounin.ru>
parents:
7005
diff
changeset
|
166 socklen = sizeof(ngx_sockaddr_t); |
fef61d26da39
Fixed buffer overread with unix sockets after accept().
Maxim Dounin <mdounin@mdounin.ru>
parents:
7005
diff
changeset
|
167 } |
fef61d26da39
Fixed buffer overread with unix sockets after accept().
Maxim Dounin <mdounin@mdounin.ru>
parents:
7005
diff
changeset
|
168 |
714 | 169 c->sockaddr = ngx_palloc(c->pool, socklen); |
543 | 170 if (c->sockaddr == NULL) { |
171 ngx_close_accepted_connection(c); | |
172 return; | |
173 } | |
174 | |
6559
adf25b8d0431
Introduced the ngx_sockaddr_t type.
Ruslan Ermilov <ru@nginx.com>
parents:
6532
diff
changeset
|
175 ngx_memcpy(c->sockaddr, &sa, socklen); |
543 | 176 |
177 log = ngx_palloc(c->pool, sizeof(ngx_log_t)); | |
178 if (log == NULL) { | |
179 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
|
180 return; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
182 |
6125
4dc8e7b62216
Removed the obsolete aio module.
Ruslan Ermilov <ru@nginx.com>
parents:
5820
diff
changeset
|
183 /* 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
|
184 |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
185 if (ngx_inherited_nonblocking) { |
6125
4dc8e7b62216
Removed the obsolete aio module.
Ruslan Ermilov <ru@nginx.com>
parents:
5820
diff
changeset
|
186 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
|
187 if (ngx_blocking(s) == -1) { |
543 | 188 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
|
189 ngx_blocking_n " failed"); |
543 | 190 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
|
191 return; |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
192 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
193 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
194 |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
195 } else { |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
196 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
|
197 if (ngx_nonblocking(s) == -1) { |
543 | 198 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
|
199 ngx_nonblocking_n " failed"); |
543 | 200 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
|
201 return; |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
202 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
203 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
204 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
205 |
543 | 206 *log = ls->log; |
207 | |
208 c->recv = ngx_recv; | |
209 c->send = ngx_send; | |
577 | 210 c->recv_chain = ngx_recv_chain; |
543 | 211 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
|
212 |
543 | 213 c->log = log; |
214 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
|
215 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
216 c->socklen = socklen; |
543 | 217 c->listening = ls; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
218 c->local_sockaddr = ls->sockaddr; |
5463
1ab1cf63f885
Core: keep the length of the local sockaddr.
Ruslan Ermilov <ru@nginx.com>
parents:
5360
diff
changeset
|
219 c->local_socklen = ls->socklen; |
543 | 220 |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
221 #if (NGX_HAVE_UNIX_DOMAIN) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
222 if (c->sockaddr->sa_family == AF_UNIX) { |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
223 c->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
224 c->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
225 #if (NGX_SOLARIS) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
226 /* 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
|
227 c->sendfile = 0; |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
228 #endif |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
229 } |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
230 #endif |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
231 |
561 | 232 rev = c->read; |
233 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
|
234 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
121
diff
changeset
|
235 wev->ready = 1; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
236 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
237 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
|
238 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
|
239 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
240 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
241 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
|
242 rev->ready = 1; |
7005
3e2d90073adf
Fixed deferred accept with EPOLLRDHUP enabled (ticket #1278).
Roman Arutyunyan <arut@nginx.com>
parents:
6692
diff
changeset
|
243 #if (NGX_HAVE_KQUEUE || NGX_HAVE_EPOLLRDHUP) |
523 | 244 rev->available = 1; |
245 #endif | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
246 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
247 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
248 rev->log = log; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
249 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
|
250 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
251 /* |
561 | 252 * 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
|
253 * 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
|
254 * |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
206
diff
changeset
|
255 * TODO: MP: - allocated in a shared memory |
561 | 256 * - 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
|
257 * 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
|
258 */ |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
259 |
561 | 260 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
|
261 |
8396
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7285
diff
changeset
|
262 c->start_time = ngx_current_msec; |
fdc3d40979b0
Introduced the "keepalive_time" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7285
diff
changeset
|
263 |
495 | 264 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
265 (void) ngx_atomic_fetch_add(ngx_stat_handled, 1); |
495 | 266 #endif |
267 | |
543 | 268 if (ls->addr_ntop) { |
2049 | 269 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
|
270 if (c->addr_text.data == NULL) { |
543 | 271 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
|
272 return; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
273 } |
577 | 274 |
5263
05ba5bce31e0
Core: extended ngx_sock_ntop() with socklen parameter.
Vladimir Homutov <vl@nginx.com>
parents:
4618
diff
changeset
|
275 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
|
276 c->addr_text.data, |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2255
diff
changeset
|
277 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
|
278 if (c->addr_text.len == 0) { |
543 | 279 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
|
280 return; |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
281 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
282 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
283 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
284 #if (NGX_DEBUG) |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
285 { |
6436 | 286 ngx_str_t addr; |
287 u_char text[NGX_SOCKADDR_STRLEN]; | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
288 |
6436 | 289 ngx_debug_accepted_connection(ecf, c); |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
290 |
5704
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
291 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
|
292 addr.data = text; |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
293 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
|
294 NGX_SOCKADDR_STRLEN, 1); |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
295 |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
296 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
|
297 "*%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
|
298 } |
524741fd50ed
Core: output client port number when logging accept event.
Ruslan Ermilov <ru@nginx.com>
parents:
5600
diff
changeset
|
299 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
300 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
301 #endif |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
302 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
303 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
|
304 if (ngx_add_conn(c) == NGX_ERROR) { |
543 | 305 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
|
306 return; |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
307 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
308 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
309 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
310 log->data = NULL; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
311 log->handler = NULL; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
312 |
543 | 313 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
|
314 |
455 | 315 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
|
316 ev->available--; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
317 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
318 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 } while (ev->available); |
8804
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
320 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
321 #if (NGX_HAVE_EPOLLEXCLUSIVE) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
322 ngx_reorder_accept_events(ls); |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
323 #endif |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
325 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
326 |
493 | 327 ngx_int_t |
328 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
|
329 { |
611 | 330 if (ngx_shmtx_trylock(&ngx_accept_mutex)) { |
331 | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
332 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
|
333 "accept mutex locked"); |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
334 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
335 if (ngx_accept_mutex_held && ngx_accept_events == 0) { |
573 | 336 return NGX_OK; |
337 } | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
338 |
573 | 339 if (ngx_enable_accept_events(cycle) == NGX_ERROR) { |
611 | 340 ngx_shmtx_unlock(&ngx_accept_mutex); |
573 | 341 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
|
342 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
343 |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
344 ngx_accept_events = 0; |
573 | 345 ngx_accept_mutex_held = 1; |
346 | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
347 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
348 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
349 |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
350 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
|
351 "accept mutex lock failed: %ui", ngx_accept_mutex_held); |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
714
diff
changeset
|
352 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
353 if (ngx_accept_mutex_held) { |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
354 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
|
355 return NGX_ERROR; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
356 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
357 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
358 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
|
359 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
360 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
361 return NGX_OK; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
362 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
363 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
364 |
7285
88a624c9b491
Events: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c.
Roman Arutyunyan <arut@nginx.com>
parents:
7284
diff
changeset
|
365 ngx_int_t |
493 | 366 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
|
367 { |
543 | 368 ngx_uint_t i; |
369 ngx_listening_t *ls; | |
370 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
|
371 |
543 | 372 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
|
373 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
|
374 |
543 | 375 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
|
376 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
377 if (c == NULL || c->read->active) { |
4618
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
378 continue; |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
379 } |
c05cfc46b3bc
Accept moderation in case of EMFILE/ENFILE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4613
diff
changeset
|
380 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
381 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
|
382 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
|
383 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
384 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
385 |
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 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
389 |
573 | 390 static ngx_int_t |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
391 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
|
392 { |
543 | 393 ngx_uint_t i; |
394 ngx_listening_t *ls; | |
395 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
|
396 |
543 | 397 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
|
398 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
|
399 |
543 | 400 c = ls[i].connection; |
401 | |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
402 if (c == NULL || !c->read->active) { |
543 | 403 continue; |
404 } | |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
405 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
406 #if (NGX_HAVE_REUSEPORT) |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
407 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
408 /* |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
409 * 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
|
410 * 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
|
411 */ |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
412 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
413 if (ls[i].reuseport && !all) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
414 continue; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
415 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
416 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
417 #endif |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6126
diff
changeset
|
418 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
419 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
|
420 == NGX_ERROR) |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
421 { |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
422 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
|
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 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
426 return NGX_OK; |
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 |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
429 |
8804
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
430 #if (NGX_HAVE_EPOLLEXCLUSIVE) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
431 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
432 static void |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
433 ngx_reorder_accept_events(ngx_listening_t *ls) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
434 { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
435 ngx_connection_t *c; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
436 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
437 /* |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
438 * Linux with EPOLLEXCLUSIVE usually notifies only the process which |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
439 * was first to add the listening socket to the epoll instance. As |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
440 * a result most of the connections are handled by the first worker |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
441 * process. To fix this, we re-add the socket periodically, so other |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
442 * workers will get a chance to accept connections. |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
443 */ |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
444 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
445 if (!ngx_use_exclusive_accept) { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
446 return; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
447 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
448 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
449 #if (NGX_HAVE_REUSEPORT) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
450 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
451 if (ls->reuseport) { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
452 return; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
453 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
454 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
455 #endif |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
456 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
457 c = ls->connection; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
458 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
459 if (c->requests++ % 16 != 0 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
460 && ngx_accept_disabled <= 0) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
461 { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
462 return; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
463 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
464 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
465 if (ngx_del_event(c->read, NGX_READ_EVENT, NGX_DISABLE_EVENT) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
466 == NGX_ERROR) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
467 { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
468 return; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
469 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
470 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
471 if (ngx_add_event(c->read, NGX_READ_EVENT, NGX_EXCLUSIVE_EVENT) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
472 == NGX_ERROR) |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
473 { |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
474 return; |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
475 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
476 } |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
477 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
478 #endif |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
479 |
e2d07e4ec636
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8396
diff
changeset
|
480 |
493 | 481 static void |
543 | 482 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
|
483 { |
543 | 484 ngx_socket_t fd; |
485 | |
486 ngx_free_connection(c); | |
487 | |
488 fd = c->fd; | |
489 c->fd = (ngx_socket_t) -1; | |
490 | |
7285
88a624c9b491
Events: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c.
Roman Arutyunyan <arut@nginx.com>
parents:
7284
diff
changeset
|
491 if (ngx_close_socket(fd) == -1) { |
543 | 492 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
|
493 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
|
494 } |
495 | 495 |
543 | 496 if (c->pool) { |
497 ngx_destroy_pool(c->pool); | |
498 } | |
499 | |
495 | 500 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2723
diff
changeset
|
501 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); |
495 | 502 #endif |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
503 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
504 |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
505 |
543 | 506 u_char * |
493 | 507 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
|
508 { |
543 | 509 return ngx_snprintf(buf, len, " while accepting new connection on %V", |
510 log->data); | |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
511 } |
6436 | 512 |
513 | |
514 #if (NGX_DEBUG) | |
515 | |
7285
88a624c9b491
Events: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c.
Roman Arutyunyan <arut@nginx.com>
parents:
7284
diff
changeset
|
516 void |
6436 | 517 ngx_debug_accepted_connection(ngx_event_conf_t *ecf, ngx_connection_t *c) |
518 { | |
519 struct sockaddr_in *sin; | |
520 ngx_cidr_t *cidr; | |
521 ngx_uint_t i; | |
522 #if (NGX_HAVE_INET6) | |
523 struct sockaddr_in6 *sin6; | |
524 ngx_uint_t n; | |
525 #endif | |
526 | |
527 cidr = ecf->debug_connection.elts; | |
528 for (i = 0; i < ecf->debug_connection.nelts; i++) { | |
529 if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) { | |
530 goto next; | |
531 } | |
532 | |
533 switch (cidr[i].family) { | |
534 | |
535 #if (NGX_HAVE_INET6) | |
536 case AF_INET6: | |
537 sin6 = (struct sockaddr_in6 *) c->sockaddr; | |
538 for (n = 0; n < 16; n++) { | |
539 if ((sin6->sin6_addr.s6_addr[n] | |
540 & cidr[i].u.in6.mask.s6_addr[n]) | |
541 != cidr[i].u.in6.addr.s6_addr[n]) | |
542 { | |
543 goto next; | |
544 } | |
545 } | |
546 break; | |
547 #endif | |
548 | |
549 #if (NGX_HAVE_UNIX_DOMAIN) | |
550 case AF_UNIX: | |
551 break; | |
552 #endif | |
553 | |
554 default: /* AF_INET */ | |
555 sin = (struct sockaddr_in *) c->sockaddr; | |
556 if ((sin->sin_addr.s_addr & cidr[i].u.in.mask) | |
557 != cidr[i].u.in.addr) | |
558 { | |
559 goto next; | |
560 } | |
561 break; | |
562 } | |
563 | |
564 c->log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL; | |
565 break; | |
566 | |
567 next: | |
568 continue; | |
569 } | |
570 } | |
571 | |
572 #endif |