Mercurial > hg > nginx-quic
annotate src/event/ngx_event.c @ 8743:5d09596909c6 stable-1.20
Upstream: fixed timeouts with gRPC, SSL and select (ticket #2229).
With SSL it is possible that an established connection is ready for
reading after the handshake. Further, events might be already disabled
in case of level-triggered event methods. If this happens and
ngx_http_upstream_send_request() blocks waiting for some data from
the upstream, such as flow control in case of gRPC, the connection
will time out due to no read events on the upstream connection.
Fix is to explicitly check the c->read->ready flag if sending request
blocks and post a read event if it is set.
Note that while it is possible to modify ngx_ssl_handshake() to keep
read events active, this won't completely resolve the issue, since
there can be data already received during the SSL handshake
(see 573bd30e46b4).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 20 Aug 2021 03:53:56 +0300 |
parents | 2ed5d03c2d90 |
children | f1986657fc26 c860f0b7010c |
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:
435
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:
435
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:
435
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:
435
diff
changeset
|
6 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
9 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
11 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
12 |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
13 #define DEFAULT_CONNECTIONS 512 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
14 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
467 | 16 extern ngx_module_t ngx_kqueue_module; |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
17 extern ngx_module_t ngx_eventport_module; |
467 | 18 extern ngx_module_t ngx_devpoll_module; |
19 extern ngx_module_t ngx_epoll_module; | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
20 extern ngx_module_t ngx_select_module; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
21 |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
22 |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
23 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf); |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
24 static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle); |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
25 static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
26 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
27 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
28 static char *ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd, |
509 | 29 void *conf); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
30 static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
31 static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, |
509 | 32 void *conf); |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
33 |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
34 static void *ngx_event_core_create_conf(ngx_cycle_t *cycle); |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
35 static char *ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf); |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
36 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
37 |
563 | 38 static ngx_uint_t ngx_timer_resolution; |
39 sig_atomic_t ngx_event_timer_alarm; | |
40 | |
495 | 41 static ngx_uint_t ngx_event_max_module; |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
42 |
495 | 43 ngx_uint_t ngx_event_flags; |
44 ngx_event_actions_t ngx_event_actions; | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
45 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
47 static ngx_atomic_t connection_counter = 1; |
493 | 48 ngx_atomic_t *ngx_connection_counter = &connection_counter; |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
49 |
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
50 |
493 | 51 ngx_atomic_t *ngx_accept_mutex_ptr; |
611 | 52 ngx_shmtx_t ngx_accept_mutex; |
53 ngx_uint_t ngx_use_accept_mutex; | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
54 ngx_uint_t ngx_accept_events; |
495 | 55 ngx_uint_t ngx_accept_mutex_held; |
56 ngx_msec_t ngx_accept_mutex_delay; | |
57 ngx_int_t ngx_accept_disabled; | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
60 #if (NGX_STAT_STUB) |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
61 |
6922
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
62 static ngx_atomic_t ngx_stat_accepted0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
63 ngx_atomic_t *ngx_stat_accepted = &ngx_stat_accepted0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
64 static ngx_atomic_t ngx_stat_handled0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
65 ngx_atomic_t *ngx_stat_handled = &ngx_stat_handled0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
66 static ngx_atomic_t ngx_stat_requests0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
67 ngx_atomic_t *ngx_stat_requests = &ngx_stat_requests0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
68 static ngx_atomic_t ngx_stat_active0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
69 ngx_atomic_t *ngx_stat_active = &ngx_stat_active0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
70 static ngx_atomic_t ngx_stat_reading0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
71 ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
72 static ngx_atomic_t ngx_stat_writing0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
73 ngx_atomic_t *ngx_stat_writing = &ngx_stat_writing0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
74 static ngx_atomic_t ngx_stat_waiting0; |
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
75 ngx_atomic_t *ngx_stat_waiting = &ngx_stat_waiting0; |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
76 |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
77 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
78 |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
79 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
80 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
81 static ngx_command_t ngx_events_commands[] = { |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
82 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
83 { ngx_string("events"), |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
84 NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
85 ngx_events_block, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
86 0, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
87 0, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
88 NULL }, |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
89 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
90 ngx_null_command |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
91 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
92 |
577 | 93 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
94 static ngx_core_module_t ngx_events_module_ctx = { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
95 ngx_string("events"), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
96 NULL, |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
97 ngx_event_init_conf |
577 | 98 }; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
99 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
100 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
101 ngx_module_t ngx_events_module = { |
509 | 102 NGX_MODULE_V1, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
103 &ngx_events_module_ctx, /* module context */ |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
104 ngx_events_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
105 NGX_CORE_MODULE, /* module type */ |
541 | 106 NULL, /* init master */ |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
107 NULL, /* init module */ |
541 | 108 NULL, /* init process */ |
109 NULL, /* init thread */ | |
110 NULL, /* exit thread */ | |
111 NULL, /* exit process */ | |
112 NULL, /* exit master */ | |
113 NGX_MODULE_V1_PADDING | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
114 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
115 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
116 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
117 static ngx_str_t event_core_name = ngx_string("event_core"); |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
118 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
119 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
120 static ngx_command_t ngx_event_core_commands[] = { |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
121 |
543 | 122 { ngx_string("worker_connections"), |
123 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
124 ngx_event_connections, | |
125 0, | |
126 0, | |
127 NULL }, | |
128 | |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
129 { ngx_string("use"), |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
130 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
131 ngx_event_use, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
132 0, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
133 0, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
134 NULL }, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
135 |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
136 { ngx_string("multi_accept"), |
667 | 137 NGX_EVENT_CONF|NGX_CONF_FLAG, |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
138 ngx_conf_set_flag_slot, |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
139 0, |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
140 offsetof(ngx_event_conf_t, multi_accept), |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
141 NULL }, |
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
142 |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
143 { ngx_string("accept_mutex"), |
667 | 144 NGX_EVENT_CONF|NGX_CONF_FLAG, |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
145 ngx_conf_set_flag_slot, |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
146 0, |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
147 offsetof(ngx_event_conf_t, accept_mutex), |
611 | 148 NULL }, |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
149 |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
150 { ngx_string("accept_mutex_delay"), |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
151 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
152 ngx_conf_set_msec_slot, |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
153 0, |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
154 offsetof(ngx_event_conf_t, accept_mutex_delay), |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
155 NULL }, |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
156 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
157 { ngx_string("debug_connection"), |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
158 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
159 ngx_event_debug_connection, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
160 0, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
161 0, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
162 NULL }, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
163 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
164 ngx_null_command |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
165 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
166 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
167 |
6922
a72886067bbb
Added missing static specifiers.
Eran Kornblau <erankor@gmail.com>
parents:
6635
diff
changeset
|
168 static ngx_event_module_t ngx_event_core_module_ctx = { |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
169 &event_core_name, |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
170 ngx_event_core_create_conf, /* create configuration */ |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
171 ngx_event_core_init_conf, /* init configuration */ |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
172 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6018
diff
changeset
|
173 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
174 }; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
175 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
176 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
177 ngx_module_t ngx_event_core_module = { |
509 | 178 NGX_MODULE_V1, |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
179 &ngx_event_core_module_ctx, /* module context */ |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
180 ngx_event_core_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
181 NGX_EVENT_MODULE, /* module type */ |
541 | 182 NULL, /* init master */ |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
183 ngx_event_module_init, /* init module */ |
541 | 184 ngx_event_process_init, /* init process */ |
185 NULL, /* init thread */ | |
186 NULL, /* exit thread */ | |
187 NULL, /* exit process */ | |
188 NULL, /* exit master */ | |
189 NGX_MODULE_V1_PADDING | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
190 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
191 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
192 |
563 | 193 void |
194 ngx_process_events_and_timers(ngx_cycle_t *cycle) | |
195 { | |
196 ngx_uint_t flags; | |
567 | 197 ngx_msec_t timer, delta; |
563 | 198 |
199 if (ngx_timer_resolution) { | |
200 timer = NGX_TIMER_INFINITE; | |
201 flags = 0; | |
202 | |
203 } else { | |
204 timer = ngx_event_find_timer(); | |
205 flags = NGX_UPDATE_TIME; | |
206 | |
6113
36d99c042652
Replaced the remaining NGX_OLD_THREADS check with NGX_WIN32.
Ruslan Ermilov <ru@nginx.com>
parents:
6031
diff
changeset
|
207 #if (NGX_WIN32) |
36d99c042652
Replaced the remaining NGX_OLD_THREADS check with NGX_WIN32.
Ruslan Ermilov <ru@nginx.com>
parents:
6031
diff
changeset
|
208 |
36d99c042652
Replaced the remaining NGX_OLD_THREADS check with NGX_WIN32.
Ruslan Ermilov <ru@nginx.com>
parents:
6031
diff
changeset
|
209 /* handle signals from master in case of network inactivity */ |
563 | 210 |
211 if (timer == NGX_TIMER_INFINITE || timer > 500) { | |
212 timer = 500; | |
213 } | |
214 | |
215 #endif | |
216 } | |
217 | |
611 | 218 if (ngx_use_accept_mutex) { |
563 | 219 if (ngx_accept_disabled > 0) { |
220 ngx_accept_disabled--; | |
221 | |
222 } else { | |
223 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { | |
224 return; | |
225 } | |
226 | |
227 if (ngx_accept_mutex_held) { | |
228 flags |= NGX_POST_EVENTS; | |
229 | |
230 } else { | |
231 if (timer == NGX_TIMER_INFINITE | |
232 || timer > ngx_accept_mutex_delay) | |
233 { | |
234 timer = ngx_accept_mutex_delay; | |
235 } | |
236 } | |
237 } | |
238 } | |
239 | |
7584
9d2ad2fb4423
SSL: available bytes handling (ticket #1431).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7316
diff
changeset
|
240 if (!ngx_queue_empty(&ngx_posted_next_events)) { |
7617
f1720934c45b
SSL: reworked posted next events again.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7612
diff
changeset
|
241 ngx_event_move_posted_next(cycle); |
7584
9d2ad2fb4423
SSL: available bytes handling (ticket #1431).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7316
diff
changeset
|
242 timer = 0; |
9d2ad2fb4423
SSL: available bytes handling (ticket #1431).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7316
diff
changeset
|
243 } |
9d2ad2fb4423
SSL: available bytes handling (ticket #1431).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7316
diff
changeset
|
244 |
567 | 245 delta = ngx_current_msec; |
246 | |
563 | 247 (void) ngx_process_events(cycle, timer, flags); |
248 | |
567 | 249 delta = ngx_current_msec - delta; |
250 | |
251 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | |
252 "timer delta: %M", delta); | |
253 | |
5821
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
254 ngx_event_process_posted(cycle, &ngx_posted_accept_events); |
563 | 255 |
256 if (ngx_accept_mutex_held) { | |
611 | 257 ngx_shmtx_unlock(&ngx_accept_mutex); |
563 | 258 } |
259 | |
8369
2ed5d03c2d90
Events: fixed expiration of timers in the past.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8337
diff
changeset
|
260 ngx_event_expire_timers(); |
573 | 261 |
5821
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
262 ngx_event_process_posted(cycle, &ngx_posted_events); |
563 | 263 } |
264 | |
265 | |
509 | 266 ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1092
diff
changeset
|
267 ngx_handle_read_event(ngx_event_t *rev, ngx_uint_t flags) |
509 | 268 { |
269 if (ngx_event_flags & NGX_USE_CLEAR_EVENT) { | |
577 | 270 |
509 | 271 /* kqueue, epoll */ |
272 | |
273 if (!rev->active && !rev->ready) { | |
274 if (ngx_add_event(rev, NGX_READ_EVENT, NGX_CLEAR_EVENT) | |
275 == NGX_ERROR) | |
276 { | |
277 return NGX_ERROR; | |
278 } | |
279 } | |
577 | 280 |
509 | 281 return NGX_OK; |
282 | |
283 } else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) { | |
284 | |
285 /* select, poll, /dev/poll */ | |
286 | |
287 if (!rev->active && !rev->ready) { | |
288 if (ngx_add_event(rev, NGX_READ_EVENT, NGX_LEVEL_EVENT) | |
289 == NGX_ERROR) | |
290 { | |
291 return NGX_ERROR; | |
292 } | |
293 | |
294 return NGX_OK; | |
295 } | |
296 | |
297 if (rev->active && (rev->ready || (flags & NGX_CLOSE_EVENT))) { | |
298 if (ngx_del_event(rev, NGX_READ_EVENT, NGX_LEVEL_EVENT | flags) | |
299 == NGX_ERROR) | |
300 { | |
301 return NGX_ERROR; | |
302 } | |
303 | |
304 return NGX_OK; | |
305 } | |
306 | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
307 } else if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) { |
509 | 308 |
309 /* event ports */ | |
310 | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
311 if (!rev->active && !rev->ready) { |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
312 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
509 | 313 return NGX_ERROR; |
314 } | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
315 |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
316 return NGX_OK; |
509 | 317 } |
577 | 318 |
8337
9ca8fb98ef1c
Events: fixed eventport handling in ngx_handle_read_event().
Maxim Dounin <mdounin@mdounin.ru>
parents:
7617
diff
changeset
|
319 if (rev->oneshot && rev->ready) { |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
320 if (ngx_del_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
321 return NGX_ERROR; |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
322 } |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
323 |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
324 return NGX_OK; |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
325 } |
509 | 326 } |
327 | |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
328 /* iocp */ |
509 | 329 |
330 return NGX_OK; | |
331 } | |
332 | |
333 | |
334 ngx_int_t | |
335 ngx_handle_write_event(ngx_event_t *wev, size_t lowat) | |
336 { | |
337 ngx_connection_t *c; | |
338 | |
339 if (lowat) { | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
340 c = wev->data; |
509 | 341 |
342 if (ngx_send_lowat(c, lowat) == NGX_ERROR) { | |
343 return NGX_ERROR; | |
344 } | |
345 } | |
346 | |
347 if (ngx_event_flags & NGX_USE_CLEAR_EVENT) { | |
348 | |
349 /* kqueue, epoll */ | |
350 | |
351 if (!wev->active && !wev->ready) { | |
352 if (ngx_add_event(wev, NGX_WRITE_EVENT, | |
353 NGX_CLEAR_EVENT | (lowat ? NGX_LOWAT_EVENT : 0)) | |
354 == NGX_ERROR) | |
355 { | |
356 return NGX_ERROR; | |
357 } | |
358 } | |
359 | |
360 return NGX_OK; | |
361 | |
362 } else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) { | |
363 | |
364 /* select, poll, /dev/poll */ | |
365 | |
366 if (!wev->active && !wev->ready) { | |
367 if (ngx_add_event(wev, NGX_WRITE_EVENT, NGX_LEVEL_EVENT) | |
368 == NGX_ERROR) | |
369 { | |
370 return NGX_ERROR; | |
371 } | |
372 | |
373 return NGX_OK; | |
374 } | |
375 | |
376 if (wev->active && wev->ready) { | |
377 if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_LEVEL_EVENT) | |
378 == NGX_ERROR) | |
379 { | |
380 return NGX_ERROR; | |
381 } | |
382 | |
383 return NGX_OK; | |
384 } | |
385 | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
386 } else if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) { |
509 | 387 |
388 /* event ports */ | |
389 | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
390 if (!wev->active && !wev->ready) { |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
391 if (ngx_add_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { |
509 | 392 return NGX_ERROR; |
393 } | |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
394 |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
395 return NGX_OK; |
509 | 396 } |
577 | 397 |
719
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
398 if (wev->oneshot && wev->ready) { |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
399 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
400 return NGX_ERROR; |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
401 } |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
402 |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
403 return NGX_OK; |
f30b1a75fd3b
Solaris 10 event ports support
Igor Sysoev <igor@sysoev.ru>
parents:
667
diff
changeset
|
404 } |
509 | 405 } |
406 | |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
407 /* iocp */ |
509 | 408 |
409 return NGX_OK; | |
410 } | |
411 | |
412 | |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
413 static char * |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
414 ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
415 { |
7315
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
416 #if (NGX_HAVE_REUSEPORT) |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
417 ngx_uint_t i; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
418 ngx_listening_t *ls; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
419 #endif |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
420 |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
421 if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) { |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
422 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
423 "no \"events\" section in configuration"); |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
424 return NGX_CONF_ERROR; |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
425 } |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
426 |
7316
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
427 if (cycle->connection_n < cycle->listening.nelts + 1) { |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
428 |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
429 /* |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
430 * there should be at least one connection for each listening |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
431 * socket, plus an additional connection for channel |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
432 */ |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
433 |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
434 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
435 "%ui worker_connections are not enough " |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
436 "for %ui listening sockets", |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
437 cycle->connection_n, cycle->listening.nelts); |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
438 |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
439 return NGX_CONF_ERROR; |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
440 } |
8f152ca81f5f
Events: added configuration check on the number of connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7315
diff
changeset
|
441 |
7315
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
442 #if (NGX_HAVE_REUSEPORT) |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
443 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
444 ls = cycle->listening.elts; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
445 for (i = 0; i < cycle->listening.nelts; i++) { |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
446 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
447 if (!ls[i].reuseport || ls[i].worker != 0) { |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
448 continue; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
449 } |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
450 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
451 if (ngx_clone_listening(cycle, &ls[i]) != NGX_OK) { |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
452 return NGX_CONF_ERROR; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
453 } |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
454 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
455 /* cloning may change cycle->listening.elts */ |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
456 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
457 ls = cycle->listening.elts; |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
458 } |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
459 |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
460 #endif |
e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6947
diff
changeset
|
461 |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
462 return NGX_CONF_OK; |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
463 } |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
464 |
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
465 |
509 | 466 static ngx_int_t |
467 ngx_event_module_init(ngx_cycle_t *cycle) | |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
468 { |
543 | 469 void ***cf; |
605 | 470 u_char *shared; |
611 | 471 size_t size, cl; |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
472 ngx_shm_t shm; |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
473 ngx_time_t *tp; |
563 | 474 ngx_core_conf_t *ccf; |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
475 ngx_event_conf_t *ecf; |
473 | 476 |
477 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); | |
478 ecf = (*cf)[ngx_event_core_module.ctx_index]; | |
479 | |
2725 | 480 if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) { |
641 | 481 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, |
482 "using the \"%s\" event method", ecf->name); | |
483 } | |
473 | 484 |
563 | 485 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
486 |
563 | 487 ngx_timer_resolution = ccf->timer_resolution; |
488 | |
489 #if !(NGX_WIN32) | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
490 { |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
491 ngx_int_t limit; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
492 struct rlimit rlmt; |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
493 |
543 | 494 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
495 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
496 "getrlimit(RLIMIT_NOFILE) failed, ignored"); | |
497 | |
498 } else { | |
499 if (ecf->connections > (ngx_uint_t) rlmt.rlim_cur | |
500 && (ccf->rlimit_nofile == NGX_CONF_UNSET | |
501 || ecf->connections > (ngx_uint_t) ccf->rlimit_nofile)) | |
502 { | |
503 limit = (ccf->rlimit_nofile == NGX_CONF_UNSET) ? | |
504 (ngx_int_t) rlmt.rlim_cur : ccf->rlimit_nofile; | |
505 | |
506 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
507 "%ui worker_connections exceed " |
543 | 508 "open file resource limit: %i", |
509 ecf->connections, limit); | |
510 } | |
511 } | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
512 } |
605 | 513 #endif /* !(NGX_WIN32) */ |
514 | |
543 | 515 |
611 | 516 if (ccf->master == 0) { |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
517 return NGX_OK; |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
518 } |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
519 |
611 | 520 if (ngx_accept_mutex_ptr) { |
521 return NGX_OK; | |
522 } | |
523 | |
524 | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
525 /* cl should be equal to or greater than cache line size */ |
611 | 526 |
527 cl = 128; | |
528 | |
529 size = cl /* ngx_accept_mutex */ | |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
530 + cl /* ngx_connection_counter */ |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
531 + cl; /* ngx_temp_number */ |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
532 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
533 #if (NGX_STAT_STUB) |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
534 |
611 | 535 size += cl /* ngx_stat_accepted */ |
536 + cl /* ngx_stat_handled */ | |
537 + cl /* ngx_stat_requests */ | |
538 + cl /* ngx_stat_active */ | |
539 + cl /* ngx_stat_reading */ | |
5115
a29c574d61fa
Status: introduced the "ngx_stat_waiting" counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5002
diff
changeset
|
540 + cl /* ngx_stat_writing */ |
a29c574d61fa
Status: introduced the "ngx_stat_waiting" counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5002
diff
changeset
|
541 + cl; /* ngx_stat_waiting */ |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
542 |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
543 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
544 |
605 | 545 shm.size = size; |
6947
a8d7c9139831
Core: set nginx_shared_zone name via ngx_str_set().
Ruslan Ermilov <ru@nginx.com>
parents:
6922
diff
changeset
|
546 ngx_str_set(&shm.name, "nginx_shared_zone"); |
605 | 547 shm.log = cycle->log; |
548 | |
549 if (ngx_shm_alloc(&shm) != NGX_OK) { | |
358
0a03c921c81d
nginx-0.0.7-2004-06-17-21:18:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
550 return NGX_ERROR; |
0a03c921c81d
nginx-0.0.7-2004-06-17-21:18:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
551 } |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
552 |
605 | 553 shared = shm.addr; |
554 | |
330
377a955421dc
nginx-0.0.3-2004-04-29-20:34:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
325
diff
changeset
|
555 ngx_accept_mutex_ptr = (ngx_atomic_t *) shared; |
3909
0daede16d68b
use POSIX semaphores in shmtx instead of sched_yield()
Igor Sysoev <igor@sysoev.ru>
parents:
3473
diff
changeset
|
556 ngx_accept_mutex.spin = (ngx_uint_t) -1; |
611 | 557 |
4309
3f6040cd731e
Added shmtx interface to forcibly unlock mutexes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
558 if (ngx_shmtx_create(&ngx_accept_mutex, (ngx_shmtx_sh_t *) shared, |
3f6040cd731e
Added shmtx interface to forcibly unlock mutexes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
559 cycle->lock_file.data) |
611 | 560 != NGX_OK) |
561 { | |
562 return NGX_ERROR; | |
563 } | |
564 | |
565 ngx_connection_counter = (ngx_atomic_t *) (shared + 1 * cl); | |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
566 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2537
diff
changeset
|
567 (void) ngx_atomic_cmp_set(ngx_connection_counter, 0, 1); |
563 | 568 |
325
7c3323909107
nginx-0.0.3-2004-04-23-20:50:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
569 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 570 "counter: %p, %uA", |
325
7c3323909107
nginx-0.0.3-2004-04-23-20:50:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
571 ngx_connection_counter, *ngx_connection_counter); |
7c3323909107
nginx-0.0.3-2004-04-23-20:50:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
572 |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
573 ngx_temp_number = (ngx_atomic_t *) (shared + 2 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
574 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
575 tp = ngx_timeofday(); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
576 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
577 ngx_random_number = (tp->msec << 16) + ngx_pid; |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
578 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
579 #if (NGX_STAT_STUB) |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
580 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
581 ngx_stat_accepted = (ngx_atomic_t *) (shared + 3 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
582 ngx_stat_handled = (ngx_atomic_t *) (shared + 4 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
583 ngx_stat_requests = (ngx_atomic_t *) (shared + 5 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
584 ngx_stat_active = (ngx_atomic_t *) (shared + 6 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
585 ngx_stat_reading = (ngx_atomic_t *) (shared + 7 * cl); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
586 ngx_stat_writing = (ngx_atomic_t *) (shared + 8 * cl); |
5115
a29c574d61fa
Status: introduced the "ngx_stat_waiting" counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5002
diff
changeset
|
587 ngx_stat_waiting = (ngx_atomic_t *) (shared + 9 * cl); |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
588 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
589 #endif |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
590 |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
591 return NGX_OK; |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
592 } |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
593 |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
594 |
563 | 595 #if !(NGX_WIN32) |
596 | |
4759
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4613
diff
changeset
|
597 static void |
563 | 598 ngx_timer_signal_handler(int signo) |
599 { | |
600 ngx_event_timer_alarm = 1; | |
601 | |
602 #if 1 | |
603 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ngx_cycle->log, 0, "timer signal"); | |
604 #endif | |
605 } | |
606 | |
607 #endif | |
608 | |
609 | |
509 | 610 static ngx_int_t |
611 ngx_event_process_init(ngx_cycle_t *cycle) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
612 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
613 ngx_uint_t m, i; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
614 ngx_event_t *rev, *wev; |
543 | 615 ngx_listening_t *ls; |
616 ngx_connection_t *c, *next, *old; | |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
617 ngx_core_conf_t *ccf; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
618 ngx_event_conf_t *ecf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
619 ngx_event_module_t *module; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
620 |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
621 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
622 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
623 |
865 | 624 if (ccf->master && ccf->worker_processes > 1 && ecf->accept_mutex) { |
611 | 625 ngx_use_accept_mutex = 1; |
345
fade4edd61f8
nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
626 ngx_accept_mutex_held = 0; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
627 ngx_accept_mutex_delay = ecf->accept_mutex_delay; |
611 | 628 |
629 } else { | |
630 ngx_use_accept_mutex = 0; | |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
631 } |
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
632 |
5235
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
633 #if (NGX_WIN32) |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
634 |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
635 /* |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
636 * disable accept mutex on win32 as it may cause deadlock if |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
637 * grabbed by a process which can't accept connections |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
638 */ |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
639 |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
640 ngx_use_accept_mutex = 0; |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
641 |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
642 #endif |
c9fe549b127b
Win32: accept_mutex now always disabled (ticket #362).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5115
diff
changeset
|
643 |
5821
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
644 ngx_queue_init(&ngx_posted_accept_events); |
7584
9d2ad2fb4423
SSL: available bytes handling (ticket #1431).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7316
diff
changeset
|
645 ngx_queue_init(&ngx_posted_next_events); |
5821
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
646 ngx_queue_init(&ngx_posted_events); |
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
647 |
270
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
648 if (ngx_event_timer_init(cycle->log) == NGX_ERROR) { |
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
649 return NGX_ERROR; |
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
650 } |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
651 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
652 for (m = 0; cycle->modules[m]; m++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
653 if (cycle->modules[m]->type != NGX_EVENT_MODULE) { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
654 continue; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
655 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
656 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
657 if (cycle->modules[m]->ctx_index != ecf->use) { |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
658 continue; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
659 } |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
660 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
661 module = cycle->modules[m]->ctx; |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
662 |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
663 if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) { |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
664 /* fatal */ |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
665 exit(2); |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
666 } |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
667 |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
668 break; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
39
diff
changeset
|
669 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
670 |
543 | 671 #if !(NGX_WIN32) |
672 | |
563 | 673 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
674 struct sigaction sa; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
675 struct itimerval itv; |
563 | 676 |
677 ngx_memzero(&sa, sizeof(struct sigaction)); | |
678 sa.sa_handler = ngx_timer_signal_handler; | |
679 sigemptyset(&sa.sa_mask); | |
680 | |
681 if (sigaction(SIGALRM, &sa, NULL) == -1) { | |
682 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
683 "sigaction(SIGALRM) failed"); | |
684 return NGX_ERROR; | |
685 } | |
686 | |
687 itv.it_interval.tv_sec = ngx_timer_resolution / 1000; | |
688 itv.it_interval.tv_usec = (ngx_timer_resolution % 1000) * 1000; | |
689 itv.it_value.tv_sec = ngx_timer_resolution / 1000; | |
690 itv.it_value.tv_usec = (ngx_timer_resolution % 1000 ) * 1000; | |
691 | |
692 if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { | |
693 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
694 "setitimer() failed"); | |
577 | 695 } |
563 | 696 } |
697 | |
543 | 698 if (ngx_event_flags & NGX_USE_FD_EVENT) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
699 struct rlimit rlmt; |
543 | 700 |
701 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | |
702 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
703 "getrlimit(RLIMIT_NOFILE) failed"); | |
704 return NGX_ERROR; | |
705 } | |
706 | |
707 cycle->files_n = (ngx_uint_t) rlmt.rlim_cur; | |
708 | |
709 cycle->files = ngx_calloc(sizeof(ngx_connection_t *) * cycle->files_n, | |
710 cycle->log); | |
711 if (cycle->files == NULL) { | |
712 return NGX_ERROR; | |
713 } | |
714 } | |
715 | |
6266
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
716 #else |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
717 |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
718 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
719 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
720 "the \"timer_resolution\" directive is not supported " |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
721 "with the configured event method, ignored"); |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
722 ngx_timer_resolution = 0; |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
723 } |
dceb078b1156
Win32: timer_resolution now ignored with select.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6166
diff
changeset
|
724 |
543 | 725 #endif |
726 | |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
727 cycle->connections = |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
728 ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log); |
561 | 729 if (cycle->connections == NULL) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
730 return NGX_ERROR; |
112
da763a85be66
nginx-0.0.1-2003-07-04-10:03:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
109
diff
changeset
|
731 } |
da763a85be66
nginx-0.0.1-2003-07-04-10:03:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
109
diff
changeset
|
732 |
561 | 733 c = cycle->connections; |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
734 |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
735 cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
736 cycle->log); |
561 | 737 if (cycle->read_events == NULL) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
738 return NGX_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
739 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
740 |
561 | 741 rev = cycle->read_events; |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
742 for (i = 0; i < cycle->connection_n; i++) { |
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
743 rev[i].closed = 1; |
481 | 744 rev[i].instance = 1; |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
745 } |
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
746 |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
747 cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, |
481 | 748 cycle->log); |
561 | 749 if (cycle->write_events == NULL) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
750 return NGX_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
751 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
752 |
561 | 753 wev = cycle->write_events; |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
754 for (i = 0; i < cycle->connection_n; i++) { |
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
755 wev[i].closed = 1; |
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
756 } |
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
757 |
543 | 758 i = cycle->connection_n; |
759 next = NULL; | |
760 | |
761 do { | |
762 i--; | |
763 | |
764 c[i].data = next; | |
561 | 765 c[i].read = &cycle->read_events[i]; |
766 c[i].write = &cycle->write_events[i]; | |
543 | 767 c[i].fd = (ngx_socket_t) -1; |
768 | |
769 next = &c[i]; | |
770 } while (i); | |
771 | |
772 cycle->free_connections = next; | |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
773 cycle->free_connection_n = cycle->connection_n; |
543 | 774 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 /* for each listening socket */ |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
776 |
543 | 777 ls = cycle->listening.elts; |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
778 for (i = 0; i < cycle->listening.nelts; i++) { |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
779 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
780 #if (NGX_HAVE_REUSEPORT) |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
781 if (ls[i].reuseport && ls[i].worker != ngx_worker) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
782 continue; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
783 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
784 #endif |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6139
diff
changeset
|
785 |
543 | 786 c = ngx_get_connection(ls[i].fd, cycle->log); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
787 |
543 | 788 if (c == NULL) { |
789 return NGX_ERROR; | |
790 } | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
791 |
6436 | 792 c->type = ls[i].type; |
543 | 793 c->log = &ls[i].log; |
794 | |
795 c->listening = &ls[i]; | |
796 ls[i].connection = c; | |
797 | |
561 | 798 rev = c->read; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
799 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
800 rev->log = c->log; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
801 rev->accept = 1; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
802 |
469 | 803 #if (NGX_HAVE_DEFERRED_ACCEPT) |
543 | 804 rev->deferred_accept = ls[i].deferred_accept; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
805 #endif |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
806 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
807 if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) { |
543 | 808 if (ls[i].previous) { |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
809 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
810 /* |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
811 * delete the old accept events that were bound to |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
812 * the old cycle read events array |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
813 */ |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
814 |
543 | 815 old = ls[i].previous->connection; |
816 | |
817 if (ngx_del_event(old->read, NGX_READ_EVENT, NGX_CLOSE_EVENT) | |
818 == NGX_ERROR) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
819 { |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
820 return NGX_ERROR; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
821 } |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
822 |
543 | 823 old->fd = (ngx_socket_t) -1; |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
824 } |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
825 } |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
826 |
461 | 827 #if (NGX_WIN32) |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
828 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
829 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
830 ngx_iocp_conf_t *iocpcf; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1380
diff
changeset
|
831 |
509 | 832 rev->handler = ngx_event_acceptex; |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
833 |
2771
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
834 if (ngx_use_accept_mutex) { |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
835 continue; |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
836 } |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
837 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
838 if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) { |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
839 return NGX_ERROR; |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
840 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
841 |
543 | 842 ls[i].log.handler = ngx_acceptex_log_error; |
843 | |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
844 iocpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_iocp_module); |
543 | 845 if (ngx_event_post_acceptex(&ls[i], iocpcf->post_acceptex) |
846 == NGX_ERROR) | |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
276
diff
changeset
|
847 { |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
848 return NGX_ERROR; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
849 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
850 |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
851 } else { |
509 | 852 rev->handler = ngx_event_accept; |
461 | 853 |
2771
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
854 if (ngx_use_accept_mutex) { |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
855 continue; |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
856 } |
4d62ef39f08b
add listen events for win32 only after accept mutex is hold
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
857 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
858 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
859 return NGX_ERROR; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
860 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
861 } |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
862 |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
863 #else |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
864 |
6436 | 865 rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept |
866 : ngx_event_recvmsg; | |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
867 |
6155
193bbc006d5e
Fixed reuseport with accept_mutex.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6153
diff
changeset
|
868 #if (NGX_HAVE_REUSEPORT) |
6635
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
869 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
870 if (ls[i].reuseport) { |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
871 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
872 return NGX_ERROR; |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
873 } |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
874 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
875 continue; |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
876 } |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
877 |
6155
193bbc006d5e
Fixed reuseport with accept_mutex.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6153
diff
changeset
|
878 #endif |
6635
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
879 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
880 if (ngx_use_accept_mutex) { |
345
fade4edd61f8
nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
881 continue; |
fade4edd61f8
nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
882 } |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
331
diff
changeset
|
883 |
6635
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
884 #if (NGX_HAVE_EPOLLEXCLUSIVE) |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
885 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
886 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
887 && ccf->worker_processes > 1) |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
888 { |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
889 if (ngx_add_event(rev, NGX_READ_EVENT, NGX_EXCLUSIVE_EVENT) |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
890 == NGX_ERROR) |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
891 { |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
892 return NGX_ERROR; |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
893 } |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
894 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
895 continue; |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
896 } |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
897 |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
898 #endif |
6acaa638fa07
Events: support for EPOLLEXCLUSIVE.
Valentin Bartenev <vbart@nginx.com>
parents:
6633
diff
changeset
|
899 |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
900 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
901 return NGX_ERROR; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
902 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
903 |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
904 #endif |
543 | 905 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
906 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
907 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
908 return NGX_OK; |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
909 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
910 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
911 |
509 | 912 ngx_int_t |
913 ngx_send_lowat(ngx_connection_t *c, size_t lowat) | |
452 | 914 { |
915 int sndlowat; | |
916 | |
455 | 917 #if (NGX_HAVE_LOWAT_EVENT) |
452 | 918 |
455 | 919 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
452 | 920 c->write->available = lowat; |
921 return NGX_OK; | |
922 } | |
923 | |
924 #endif | |
577 | 925 |
452 | 926 if (lowat == 0 || c->sndlowat) { |
927 return NGX_OK; | |
928 } | |
929 | |
930 sndlowat = (int) lowat; | |
931 | |
932 if (setsockopt(c->fd, SOL_SOCKET, SO_SNDLOWAT, | |
1092 | 933 (const void *) &sndlowat, sizeof(int)) |
934 == -1) | |
452 | 935 { |
936 ngx_connection_error(c, ngx_socket_errno, | |
937 "setsockopt(SO_SNDLOWAT) failed"); | |
938 return NGX_ERROR; | |
939 } | |
940 | |
941 c->sndlowat = 1; | |
942 | |
943 return NGX_OK; | |
944 } | |
945 | |
946 | |
509 | 947 static char * |
948 ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
949 { |
501 | 950 char *rv; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
951 void ***ctx; |
501 | 952 ngx_uint_t i; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
953 ngx_conf_t pcf; |
501 | 954 ngx_event_module_t *m; |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
955 |
5002
39c597272c8d
Events: added check for duplicate "events" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4810
diff
changeset
|
956 if (*(void **) conf) { |
39c597272c8d
Events: added check for duplicate "events" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4810
diff
changeset
|
957 return "is duplicate"; |
39c597272c8d
Events: added check for duplicate "events" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4810
diff
changeset
|
958 } |
39c597272c8d
Events: added check for duplicate "events" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4810
diff
changeset
|
959 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
960 /* count the number of the event modules and set up their indices */ |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
961 |
6378
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6266
diff
changeset
|
962 ngx_event_max_module = ngx_count_modules(cf->cycle, NGX_EVENT_MODULE); |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
963 |
501 | 964 ctx = ngx_pcalloc(cf->pool, sizeof(void *)); |
965 if (ctx == NULL) { | |
966 return NGX_CONF_ERROR; | |
967 } | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
968 |
501 | 969 *ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)); |
970 if (*ctx == NULL) { | |
971 return NGX_CONF_ERROR; | |
972 } | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
973 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
974 *(void **) conf = ctx; |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
975 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
976 for (i = 0; cf->cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
977 if (cf->cycle->modules[i]->type != NGX_EVENT_MODULE) { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
978 continue; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
979 } |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
980 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
981 m = cf->cycle->modules[i]->ctx; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
982 |
501 | 983 if (m->create_conf) { |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
984 (*ctx)[cf->cycle->modules[i]->ctx_index] = |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
985 m->create_conf(cf->cycle); |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
986 if ((*ctx)[cf->cycle->modules[i]->ctx_index] == NULL) { |
501 | 987 return NGX_CONF_ERROR; |
988 } | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
989 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
990 } |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
991 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
992 pcf = *cf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
993 cf->ctx = ctx; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
994 cf->module_type = NGX_EVENT_MODULE; |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
995 cf->cmd_type = NGX_EVENT_CONF; |
501 | 996 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
997 rv = ngx_conf_parse(cf, NULL); |
501 | 998 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
999 *cf = pcf; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1000 |
6166 | 1001 if (rv != NGX_CONF_OK) { |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1002 return rv; |
6166 | 1003 } |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1004 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1005 for (i = 0; cf->cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1006 if (cf->cycle->modules[i]->type != NGX_EVENT_MODULE) { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1007 continue; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1008 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1009 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1010 m = cf->cycle->modules[i]->ctx; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1011 |
501 | 1012 if (m->init_conf) { |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1013 rv = m->init_conf(cf->cycle, |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1014 (*ctx)[cf->cycle->modules[i]->ctx_index]); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1015 if (rv != NGX_CONF_OK) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1016 return rv; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1017 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1018 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1019 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1020 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1021 return NGX_CONF_OK; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1022 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1023 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1024 |
509 | 1025 static char * |
1026 ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1027 { |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1028 ngx_event_conf_t *ecf = conf; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1029 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1030 ngx_str_t *value; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1031 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
1032 if (ecf->connections != NGX_CONF_UNSET_UINT) { |
2024 | 1033 return "is duplicate"; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1034 } |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1035 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1036 value = cf->args->elts; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1037 ecf->connections = ngx_atoi(value[1].data, value[1].len); |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
1038 if (ecf->connections == (ngx_uint_t) NGX_ERROR) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1039 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
461 | 1040 "invalid number \"%V\"", &value[1]); |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1041 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1042 return NGX_CONF_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1043 } |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1044 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1045 cf->cycle->connection_n = ecf->connections; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1046 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1047 return NGX_CONF_OK; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1048 } |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1049 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1050 |
509 | 1051 static char * |
1052 ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1053 { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
1054 ngx_event_conf_t *ecf = conf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1055 |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1056 ngx_int_t m; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1057 ngx_str_t *value; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1058 ngx_event_conf_t *old_ecf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1059 ngx_event_module_t *module; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1060 |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
1061 if (ecf->use != NGX_CONF_UNSET_UINT) { |
2024 | 1062 return "is duplicate"; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1063 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1064 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1065 value = cf->args->elts; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1066 |
227
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
1067 if (cf->cycle->old_cycle->conf_ctx) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1068 old_ecf = ngx_event_get_conf(cf->cycle->old_cycle->conf_ctx, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1069 ngx_event_core_module); |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1070 } else { |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1071 old_ecf = NULL; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1072 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1073 |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1074 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1075 for (m = 0; cf->cycle->modules[m]; m++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1076 if (cf->cycle->modules[m]->type != NGX_EVENT_MODULE) { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1077 continue; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1078 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1079 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1080 module = cf->cycle->modules[m]->ctx; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1081 if (module->name->len == value[1].len) { |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1082 if (ngx_strcmp(module->name->data, value[1].data) == 0) { |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1083 ecf->use = cf->cycle->modules[m]->ctx_index; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1084 ecf->name = module->name->data; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1085 |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1086 if (ngx_process == NGX_PROCESS_SINGLE |
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1087 && old_ecf |
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1088 && old_ecf->use != ecf->use) |
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1089 { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1090 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
467 | 1091 "when the server runs without a master process " |
1092 "the \"%V\" event type must be the same as " | |
1093 "in previous configuration - \"%s\" " | |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3909
diff
changeset
|
1094 "and it cannot be changed on the fly, " |
467 | 1095 "to change it you need to stop server " |
1096 "and start it again", | |
1097 &value[1], old_ecf->name); | |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
1098 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1099 return NGX_CONF_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1100 } |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1101 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1102 return NGX_CONF_OK; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1103 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1104 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1105 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1106 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1107 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
461 | 1108 "invalid event type \"%V\"", &value[1]); |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1109 |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1110 return NGX_CONF_ERROR; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1111 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1112 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1113 |
509 | 1114 static char * |
1115 ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1116 { |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1117 #if (NGX_DEBUG) |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1118 ngx_event_conf_t *ecf = conf; |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1119 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1120 ngx_int_t rc; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1121 ngx_str_t *value; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1122 ngx_url_t u; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1123 ngx_cidr_t c, *cidr; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1124 ngx_uint_t i; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1125 struct sockaddr_in *sin; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1126 #if (NGX_HAVE_INET6) |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1127 struct sockaddr_in6 *sin6; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1128 #endif |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1129 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1130 value = cf->args->elts; |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1131 |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1132 #if (NGX_HAVE_UNIX_DOMAIN) |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1133 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1134 if (ngx_strcmp(value[1].data, "unix:") == 0) { |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1135 cidr = ngx_array_push(&ecf->debug_connection); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1136 if (cidr == NULL) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1137 return NGX_CONF_ERROR; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1138 } |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1139 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1140 cidr->family = AF_UNIX; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1141 return NGX_CONF_OK; |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1142 } |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1143 |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1144 #endif |
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1145 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1146 rc = ngx_ptocidr(&value[1], &c); |
1380
b590a528fd41
ignore meaningless bits in CIDR and warn about them
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
1147 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1148 if (rc != NGX_ERROR) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1149 if (rc == NGX_DONE) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1150 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1151 "low address bits of %V are meaningless", |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1152 &value[1]); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1153 } |
1380
b590a528fd41
ignore meaningless bits in CIDR and warn about them
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
1154 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1155 cidr = ngx_array_push(&ecf->debug_connection); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1156 if (cidr == NULL) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1157 return NGX_CONF_ERROR; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1158 } |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1159 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1160 *cidr = c; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1161 |
1380
b590a528fd41
ignore meaningless bits in CIDR and warn about them
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
1162 return NGX_CONF_OK; |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1163 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1164 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1165 ngx_memzero(&u, sizeof(ngx_url_t)); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1166 u.host = value[1]; |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1167 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1168 if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1169 if (u.err) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1170 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1171 "%s in debug_connection \"%V\"", |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1172 u.err, &u.host); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1173 } |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1174 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1175 return NGX_CONF_ERROR; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1176 } |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1177 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1178 cidr = ngx_array_push_n(&ecf->debug_connection, u.naddrs); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1179 if (cidr == NULL) { |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1180 return NGX_CONF_ERROR; |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1181 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1182 |
4763
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1183 ngx_memzero(cidr, u.naddrs * sizeof(ngx_cidr_t)); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1184 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1185 for (i = 0; i < u.naddrs; i++) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1186 cidr[i].family = u.addrs[i].sockaddr->sa_family; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1187 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1188 switch (cidr[i].family) { |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1189 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1190 #if (NGX_HAVE_INET6) |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1191 case AF_INET6: |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1192 sin6 = (struct sockaddr_in6 *) u.addrs[i].sockaddr; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1193 cidr[i].u.in6.addr = sin6->sin6_addr; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1194 ngx_memset(cidr[i].u.in6.mask.s6_addr, 0xff, 16); |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1195 break; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1196 #endif |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1197 |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1198 default: /* AF_INET */ |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1199 sin = (struct sockaddr_in *) u.addrs[i].sockaddr; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1200 cidr[i].u.in.addr = sin->sin_addr.s_addr; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1201 cidr[i].u.in.mask = 0xffffffff; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1202 break; |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1203 } |
b0b93b2a1f8a
When "debug_connection" is configured with a domain name, only the first
Ruslan Ermilov <ru@nginx.com>
parents:
4759
diff
changeset
|
1204 } |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1205 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1206 #else |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1207 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1208 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1209 "\"debug_connection\" is ignored, you need to rebuild " |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1210 "nginx using --with-debug option to enable it"); |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1211 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1212 #endif |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1213 |
1380
b590a528fd41
ignore meaningless bits in CIDR and warn about them
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
1214 return NGX_CONF_OK; |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1215 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1216 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1217 |
509 | 1218 static void * |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1219 ngx_event_core_create_conf(ngx_cycle_t *cycle) |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1220 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1221 ngx_event_conf_t *ecf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1222 |
501 | 1223 ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)); |
1224 if (ecf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2771
diff
changeset
|
1225 return NULL; |
501 | 1226 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1227 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
1228 ecf->connections = NGX_CONF_UNSET_UINT; |
358
0a03c921c81d
nginx-0.0.7-2004-06-17-21:18:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
1229 ecf->use = NGX_CONF_UNSET_UINT; |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
1230 ecf->multi_accept = NGX_CONF_UNSET; |
303
00c5660d2707
nginx-0.0.3-2004-04-01-20:20:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
301
diff
changeset
|
1231 ecf->accept_mutex = NGX_CONF_UNSET; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
1232 ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC; |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1233 ecf->name = (void *) NGX_CONF_UNSET; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1234 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1235 #if (NGX_DEBUG) |
501 | 1236 |
1237 if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4, | |
4613
9ee20e074a2e
debug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov <ru@nginx.com>
parents:
4599
diff
changeset
|
1238 sizeof(ngx_cidr_t)) == NGX_ERROR) |
501 | 1239 { |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2771
diff
changeset
|
1240 return NULL; |
501 | 1241 } |
1242 | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1243 #endif |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
1244 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1245 return ecf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1246 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1247 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1248 |
509 | 1249 static char * |
4599
f947296f6b2b
Fixed master exit if there is no events section (ticket #150).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1250 ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf) |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1251 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
1252 ngx_event_conf_t *ecf = conf; |
467 | 1253 |
501 | 1254 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) |
1255 int fd; | |
1256 #endif | |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1257 ngx_int_t i; |
467 | 1258 ngx_module_t *module; |
1259 ngx_event_module_t *event_module; | |
1260 | |
1261 module = NULL; | |
1262 | |
469 | 1263 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) |
467 | 1264 |
1265 fd = epoll_create(100); | |
1266 | |
1267 if (fd != -1) { | |
4810
e1d11fb9a71f
Explicitly ignore returned value from close() in ngx_event_core_init_conf().
Andrey Belov <defan@nginx.com>
parents:
4763
diff
changeset
|
1268 (void) close(fd); |
467 | 1269 module = &ngx_epoll_module; |
1270 | |
1271 } else if (ngx_errno != NGX_ENOSYS) { | |
1272 module = &ngx_epoll_module; | |
1273 } | |
1274 | |
1275 #endif | |
1276 | |
6465 | 1277 #if (NGX_HAVE_DEVPOLL) && !(NGX_TEST_BUILD_DEVPOLL) |
467 | 1278 |
1279 module = &ngx_devpoll_module; | |
1280 | |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1281 #endif |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1282 |
469 | 1283 #if (NGX_HAVE_KQUEUE) |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1284 |
467 | 1285 module = &ngx_kqueue_module; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
250
diff
changeset
|
1286 |
467 | 1287 #endif |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1288 |
469 | 1289 #if (NGX_HAVE_SELECT) |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1290 |
467 | 1291 if (module == NULL) { |
1292 module = &ngx_select_module; | |
1293 } | |
1294 | |
355
0fb6c53fb135
nginx-0.0.7-2004-06-15-21:47:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
354
diff
changeset
|
1295 #endif |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1296 |
467 | 1297 if (module == NULL) { |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1298 for (i = 0; cycle->modules[i]; i++) { |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1299 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1300 if (cycle->modules[i]->type != NGX_EVENT_MODULE) { |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1301 continue; |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1302 } |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1303 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1304 event_module = cycle->modules[i]->ctx; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1305 |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1306 if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0) |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1307 { |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1308 continue; |
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1309 } |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1310 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
1311 module = cycle->modules[i]; |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1312 break; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1313 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1314 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1315 |
467 | 1316 if (module == NULL) { |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1317 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found"); |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1318 return NGX_CONF_ERROR; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1319 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1320 |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
1321 ngx_conf_init_uint_value(ecf->connections, DEFAULT_CONNECTIONS); |
467 | 1322 cycle->connection_n = ecf->connections; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1323 |
663 | 1324 ngx_conf_init_uint_value(ecf->use, module->ctx_index); |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
1325 |
467 | 1326 event_module = module->ctx; |
1327 ngx_conf_init_ptr_value(ecf->name, event_module->name->data); | |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
205
diff
changeset
|
1328 |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
1329 ngx_conf_init_value(ecf->multi_accept, 0); |
6633
d82b3c344e7e
Events: the "accept_mutex" directive is turned off by default.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
1330 ngx_conf_init_value(ecf->accept_mutex, 0); |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
1331 ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1332 |
573 | 1333 return NGX_CONF_OK; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1334 } |