Mercurial > hg > nginx
annotate src/event/modules/ngx_win32_select_module.c @ 3425:0189a8f4c7c3 stable-0.7
merge r2990, r3324, r3384, r3419:
various proxy/FastCGI fixes:
*) do auto redirect for proxy_pass/fastcgi_pass with variables
*) allow "proxy_pass http://$backend" without URI part
*) add conf/fastcgi.conf
*) delete u->cleanup mark, this fixes large values in $upstream_response_time,
the bug had been introduced in r3246
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 01 Feb 2010 14:01:24 +0000 |
parents | c00763aa5e1b |
children | a66d6dfd53f1 e1409e56ba7c |
rev | line source |
---|---|
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
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 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
4 */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
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> |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
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> |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
11 |
563 | 12 static ngx_int_t ngx_select_init(ngx_cycle_t *cycle, ngx_msec_t timer); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
13 static void ngx_select_done(ngx_cycle_t *cycle); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
14 static ngx_int_t ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
15 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
16 static ngx_int_t ngx_select_del_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
17 ngx_uint_t flags); |
563 | 18 static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
19 ngx_uint_t flags); | |
2780 | 20 static void ngx_select_repair_fd_sets(ngx_cycle_t *cycle); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
21 static char *ngx_select_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:
87
diff
changeset
|
22 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
23 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
24 static fd_set master_read_fd_set; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
25 static fd_set master_write_fd_set; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
26 static fd_set work_read_fd_set; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
27 static fd_set work_write_fd_set; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
29 static ngx_uint_t max_read; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
30 static ngx_uint_t max_write; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
31 static ngx_uint_t nevents; |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
32 |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
33 static ngx_event_t **event_index; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
34 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
35 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
36 static ngx_str_t select_name = ngx_string("select"); |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
37 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
38 ngx_event_module_t ngx_select_module_ctx = { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
39 &select_name, |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
40 NULL, /* create configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
41 ngx_select_init_conf, /* init configuration */ |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
43 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
44 ngx_select_add_event, /* add an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
45 ngx_select_del_event, /* delete an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
46 ngx_select_add_event, /* enable an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
47 ngx_select_del_event, /* disable an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
48 NULL, /* add an connection */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
49 NULL, /* delete an connection */ |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
50 NULL, /* process the changes */ |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
51 ngx_select_process_events, /* process the events */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
52 ngx_select_init, /* init the events */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
53 ngx_select_done /* done the events */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
54 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
55 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
56 }; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
57 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
58 ngx_module_t ngx_select_module = { |
509 | 59 NGX_MODULE_V1, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
60 &ngx_select_module_ctx, /* module context */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
61 NULL, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
62 NGX_EVENT_MODULE, /* module type */ |
541 | 63 NULL, /* init master */ |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
64 NULL, /* init module */ |
541 | 65 NULL, /* init process */ |
66 NULL, /* init thread */ | |
67 NULL, /* exit thread */ | |
68 NULL, /* exit process */ | |
69 NULL, /* exit master */ | |
70 NGX_MODULE_V1_PADDING | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
71 }; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
72 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
73 |
501 | 74 static ngx_int_t |
563 | 75 ngx_select_init(ngx_cycle_t *cycle, ngx_msec_t timer) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 { |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
77 ngx_event_t **index; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
78 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
79 if (event_index == NULL) { |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
80 FD_ZERO(&master_read_fd_set); |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
81 FD_ZERO(&master_write_fd_set); |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
82 nevents = 0; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
83 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
85 if (ngx_process == NGX_PROCESS_WORKER |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
86 || cycle->old_cycle == NULL |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
87 || cycle->old_cycle->connection_n < cycle->connection_n) |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
88 { |
501 | 89 index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, |
90 cycle->log); | |
91 if (index == NULL) { | |
92 return NGX_ERROR; | |
93 } | |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
94 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
95 if (event_index) { |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
96 ngx_memcpy(index, event_index, sizeof(ngx_event_t *) * nevents); |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
97 ngx_free(event_index); |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
98 } |
563 | 99 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
100 event_index = index; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
101 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
103 ngx_io = ngx_os_io; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
104 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
105 ngx_event_actions = ngx_select_module_ctx.actions; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
106 |
563 | 107 ngx_event_flags = NGX_USE_LEVEL_EVENT; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
2813
c00763aa5e1b
divide select module into two modules: Unix and Win32 ones
Igor Sysoev <igor@sysoev.ru>
parents:
2809
diff
changeset
|
109 max_read = 0; |
c00763aa5e1b
divide select module into two modules: Unix and Win32 ones
Igor Sysoev <igor@sysoev.ru>
parents:
2809
diff
changeset
|
110 max_write = 0; |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
111 |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
112 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
115 |
501 | 116 static void |
117 ngx_select_done(ngx_cycle_t *cycle) | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
118 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
119 ngx_free(event_index); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
120 |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
121 event_index = NULL; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
122 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
123 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
124 |
501 | 125 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
126 ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
128 ngx_connection_t *c; |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
129 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
130 c = ev->data; |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
131 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
230
diff
changeset
|
132 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
133 "select add event fd:%d ev:%i", c->fd, event); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
135 if (ev->index != NGX_INVALID_INDEX) { |
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
136 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
137 "select event fd:%d ev:%i is already set", c->fd, event); |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
138 return NGX_OK; |
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
139 } |
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
140 |
2808
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
141 if ((event == NGX_READ_EVENT && ev->write) |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
142 || (event == NGX_WRITE_EVENT && !ev->write)) |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
143 { |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
144 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
145 "invalid select %s event fd:%d ev:%i", |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
146 ev->write ? "write" : "read", c->fd, event); |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
147 return NGX_ERROR; |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
148 } |
b7b2b0ea3366
test event type to prevent errors
Igor Sysoev <igor@sysoev.ru>
parents:
2781
diff
changeset
|
149 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
150 if ((event == NGX_READ_EVENT) && (max_read >= FD_SETSIZE) |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
151 || (event == NGX_WRITE_EVENT) && (max_write >= FD_SETSIZE)) |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
152 { |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
153 ngx_log_error(NGX_LOG_ERR, ev->log, 0, |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
154 "maximum number of descriptors " |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
155 "supported by select() is %d", FD_SETSIZE); |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
156 return NGX_ERROR; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
159 if (event == NGX_READ_EVENT) { |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
160 FD_SET(c->fd, &master_read_fd_set); |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
161 max_read++; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
163 } else if (event == NGX_WRITE_EVENT) { |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
164 FD_SET(c->fd, &master_write_fd_set); |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
165 max_write++; |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
166 } |
179
9f3a78b06c48
nginx-0.0.1-2003-11-11-21:13:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
178
diff
changeset
|
167 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
168 ev->active = 1; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
170 event_index[nevents] = ev; |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
171 ev->index = nevents; |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
172 nevents++; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
174 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
175 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
177 |
501 | 178 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
179 ngx_select_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 { |
2809 | 181 ngx_event_t *e; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
182 ngx_connection_t *c; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
183 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
184 c = ev->data; |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
185 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
186 ev->active = 0; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
187 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
188 if (ev->index == NGX_INVALID_INDEX) { |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
189 return NGX_OK; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
190 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
191 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
230
diff
changeset
|
192 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
193 "select del event fd:%d ev:%i", c->fd, event); |
23
f540a63026c9
nginx-0.0.1-2002-12-06-19:32:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
194 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
195 if (event == NGX_READ_EVENT) { |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
196 FD_CLR(c->fd, &master_read_fd_set); |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
197 max_read--; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
199 } else if (event == NGX_WRITE_EVENT) { |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
200 FD_CLR(c->fd, &master_write_fd_set); |
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
201 max_write--; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 } |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
203 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
708
diff
changeset
|
204 if (ev->index < --nevents) { |
2809 | 205 e = event_index[nevents]; |
206 event_index[ev->index] = e; | |
207 e->index = ev->index; | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
210 ev->index = NGX_INVALID_INDEX; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
211 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
212 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
215 |
501 | 216 static ngx_int_t |
563 | 217 ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
218 ngx_uint_t flags) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 { |
2778 | 220 int ready, nready; |
221 ngx_err_t err; | |
222 ngx_uint_t i, found; | |
223 ngx_event_t *ev, **queue; | |
224 struct timeval tv, *tp; | |
225 ngx_connection_t *c; | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
227 #if (NGX_DEBUG) |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
228 if (cycle->log->log_level & NGX_LOG_DEBUG_ALL) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
229 for (i = 0; i < nevents; i++) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
230 ev = event_index[i]; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
231 c = ev->data; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
232 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
233 "select event: fd:%d wr:%d", c->fd, ev->write); |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
321
diff
changeset
|
234 } |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
235 } |
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
236 #endif |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
238 if (timer == NGX_TIMER_INFINITE) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
239 tp = NULL; |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
240 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
241 } else { |
557 | 242 tv.tv_sec = (long) (timer / 1000); |
243 tv.tv_usec = (long) ((timer % 1000) * 1000); | |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
244 tp = &tv; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
245 } |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
246 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
247 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
557 | 248 "select timer: %M", timer); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
250 work_read_fd_set = master_read_fd_set; |
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
251 work_write_fd_set = master_write_fd_set; |
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
252 |
2777
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
253 if (max_read || max_write) { |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
254 ready = select(0, &work_read_fd_set, &work_write_fd_set, NULL, tp); |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
255 |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
256 } else { |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
257 |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
258 /* |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
259 * Winsock select() requires that at least one descriptor set must be |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
260 * be non-null, and any non-null descriptor set must contain at least |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
261 * one handle to a socket. Otherwise select() returns WSAEINVAL. |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
262 */ |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
263 |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
264 ngx_msleep(timer); |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
265 |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
266 ready = 0; |
7615a6c5fb54
handle Winsock select() WSAEINVAL
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
267 } |
563 | 268 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
269 if (ready == -1) { |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
270 err = ngx_socket_errno; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
271 } else { |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
272 err = 0; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 |
563 | 275 if (flags & NGX_UPDATE_TIME) { |
276 ngx_time_update(0, 0); | |
277 } | |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
278 |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
279 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
280 "select ready %d", ready); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
230
diff
changeset
|
281 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
282 if (err) { |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
283 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, "select() failed"); |
2780 | 284 |
285 if (err == WSAENOTSOCK) { | |
286 ngx_select_repair_fd_sets(cycle); | |
287 } | |
288 | |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
289 return NGX_ERROR; |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
290 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 |
567 | 292 if (ready == 0) { |
293 if (timer != NGX_TIMER_INFINITE) { | |
294 return NGX_OK; | |
295 } | |
296 | |
297 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
298 "select() returned no events without timeout"); | |
299 return NGX_ERROR; | |
563 | 300 } |
301 | |
302 ngx_mutex_lock(ngx_posted_events_mutex); | |
303 | |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
304 nready = 0; |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
305 |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
306 for (i = 0; i < nevents; i++) { |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
307 ev = event_index[i]; |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
308 c = ev->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
309 found = 0; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 if (ev->write) { |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
312 if (FD_ISSET(c->fd, &work_write_fd_set)) { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
313 found = 1; |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
314 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
230
diff
changeset
|
315 "select write %d", c->fd); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 } else { |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
319 if (FD_ISSET(c->fd, &work_read_fd_set)) { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
320 found = 1; |
302
1526e7686b20
nginx-0.0.3-2004-04-01-10:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
321 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
230
diff
changeset
|
322 "select read %d", c->fd); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
323 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
325 |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
326 if (found) { |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
327 ev->ready = 1; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
328 |
563 | 329 queue = (ngx_event_t **) (ev->accept ? &ngx_posted_accept_events: |
330 &ngx_posted_events); | |
577 | 331 ngx_locked_post_event(ev, queue); |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
332 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
333 nready++; |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
334 } |
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
13
diff
changeset
|
335 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
336 |
563 | 337 ngx_mutex_unlock(ngx_posted_events_mutex); |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
338 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
339 if (ready != nready) { |
2781
f545c81e5ddb
try to repair the case "select ready != events"
Igor Sysoev <igor@sysoev.ru>
parents:
2780
diff
changeset
|
340 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
f545c81e5ddb
try to repair the case "select ready != events"
Igor Sysoev <igor@sysoev.ru>
parents:
2780
diff
changeset
|
341 "select ready != events: %d:%d", ready, nready); |
f545c81e5ddb
try to repair the case "select ready != events"
Igor Sysoev <igor@sysoev.ru>
parents:
2780
diff
changeset
|
342 |
f545c81e5ddb
try to repair the case "select ready != events"
Igor Sysoev <igor@sysoev.ru>
parents:
2780
diff
changeset
|
343 ngx_select_repair_fd_sets(cycle); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
344 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
345 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
346 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
347 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
348 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
349 |
2780 | 350 static void |
351 ngx_select_repair_fd_sets(ngx_cycle_t *cycle) | |
352 { | |
353 int n; | |
2813
c00763aa5e1b
divide select module into two modules: Unix and Win32 ones
Igor Sysoev <igor@sysoev.ru>
parents:
2809
diff
changeset
|
354 u_int i; |
2780 | 355 socklen_t len; |
356 ngx_err_t err; | |
357 ngx_socket_t s; | |
358 | |
359 for (i = 0; i < master_read_fd_set.fd_count; i++) { | |
360 | |
361 s = master_read_fd_set.fd_array[i]; | |
362 len = sizeof(int); | |
363 | |
364 if (getsockopt(s, SOL_SOCKET, SO_TYPE, (char *) &n, &len) == -1) { | |
365 err = ngx_socket_errno; | |
366 | |
367 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, | |
368 "invalid descriptor #%d in read fd_set", s); | |
369 | |
370 FD_CLR(s, &master_read_fd_set); | |
371 } | |
372 } | |
373 | |
374 for (i = 0; i < master_write_fd_set.fd_count; i++) { | |
375 | |
376 s = master_write_fd_set.fd_array[i]; | |
377 len = sizeof(int); | |
378 | |
379 if (getsockopt(s, SOL_SOCKET, SO_TYPE, (char *) &n, &len) == -1) { | |
380 err = ngx_socket_errno; | |
381 | |
382 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, | |
383 "invalid descriptor #%d in write fd_set", s); | |
384 | |
385 FD_CLR(s, &master_write_fd_set); | |
386 } | |
387 } | |
388 } | |
389 | |
390 | |
501 | 391 static char * |
392 ngx_select_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:
87
diff
changeset
|
393 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
394 ngx_event_conf_t *ecf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
395 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
396 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
397 |
321
32847588a82a
nginx-0.0.3-2004-04-19-20:36:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
398 if (ecf->use != ngx_select_module.ctx_index) { |
32847588a82a
nginx-0.0.3-2004-04-19-20:36:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
399 return NGX_CONF_OK; |
32847588a82a
nginx-0.0.3-2004-04-19-20:36:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
400 } |
32847588a82a
nginx-0.0.3-2004-04-19-20:36:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
401 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
402 return NGX_CONF_OK; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
403 } |