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