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