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