comparison src/event/modules/ngx_poll_module.c @ 326:f70f2f565fe0 NGINX_0_5_33

nginx 0.5.33 *) Change: now by default the "echo" SSI command uses entity encoding. *) Feature: the "encoding" parameter in the "echo" SSI command. *) Change: mail proxy was split on three modules: pop3, imap and smtp. *) Feature: the --without-mail_pop3_module, --without-mail_imap_module, and --without-mail_smtp_module configuration parameters. *) Feature: the "smtp_greeting_delay" and "smtp_client_buffer" directives of the ngx_mail_smtp_module. *) Feature: the "server_name" and "valid_referers" directives support regular expressions. *) Feature: the "server_name", "map", and "valid_referers" directives support the "www.example.*" wildcards. *) Bugfix: sub_filter did not work with empty substitution. *) Bugfix: in sub_filter parsing. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used. *) Bugfix: nginx supported low case only "close" and "keep-alive" values in the "Connection" request header line; bug appeared in 0.5.32. *) Bugfix: nginx could not start on Solaris if the shared PCRE library located in non-standard place was used.
author Igor Sysoev <http://sysoev.ru>
date Wed, 07 Nov 2007 00:00:00 +0300
parents c982febb7588
children
comparison
equal deleted inserted replaced
325:5bb1b28ddeaa 326:f70f2f565fe0
9 #include <ngx_event.h> 9 #include <ngx_event.h>
10 10
11 11
12 static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle, ngx_msec_t timer); 12 static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
13 static void ngx_poll_done(ngx_cycle_t *cycle); 13 static void ngx_poll_done(ngx_cycle_t *cycle);
14 static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags); 14 static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, ngx_int_t event,
15 static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags); 15 ngx_uint_t flags);
16 static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, ngx_int_t event,
17 ngx_uint_t flags);
16 static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, 18 static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
17 ngx_uint_t flags); 19 ngx_uint_t flags);
18 static char *ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf); 20 static char *ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf);
19 21
20 22
21 static struct pollfd *event_list; 23 static struct pollfd *event_list;
22 static int nevents; 24 static ngx_int_t nevents;
23 25
24 26
25 static ngx_str_t poll_name = ngx_string("poll"); 27 static ngx_str_t poll_name = ngx_string("poll");
26 28
27 ngx_event_module_t ngx_poll_module_ctx = { 29 ngx_event_module_t ngx_poll_module_ctx = {
106 event_list = NULL; 108 event_list = NULL;
107 } 109 }
108 110
109 111
110 static ngx_int_t 112 static ngx_int_t
111 ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags) 113 ngx_poll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
112 { 114 {
113 ngx_event_t *e; 115 ngx_event_t *e;
114 ngx_connection_t *c; 116 ngx_connection_t *c;
115 117
116 c = ev->data; 118 c = ev->data;
117 119
118 ev->active = 1; 120 ev->active = 1;
119 121
120 if (ev->index != NGX_INVALID_INDEX) { 122 if (ev->index != NGX_INVALID_INDEX) {
121 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, 123 ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
122 "poll event fd:%d ev:%d is already set", c->fd, event); 124 "poll event fd:%d ev:%i is already set", c->fd, event);
123 return NGX_OK; 125 return NGX_OK;
124 } 126 }
125 127
126 if (event == NGX_READ_EVENT) { 128 if (event == NGX_READ_EVENT) {
127 e = c->write; 129 e = c->write;
135 event = POLLOUT; 137 event = POLLOUT;
136 #endif 138 #endif
137 } 139 }
138 140
139 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, 141 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
140 "poll add event: fd:%d ev:%d", c->fd, event); 142 "poll add event: fd:%d ev:%i", c->fd, event);
141 143
142 if (e == NULL || e->index == NGX_INVALID_INDEX) { 144 if (e == NULL || e->index == NGX_INVALID_INDEX) {
143 event_list[nevents].fd = c->fd; 145 event_list[nevents].fd = c->fd;
144 event_list[nevents].events = event; 146 event_list[nevents].events = (short) event;
145 event_list[nevents].revents = 0; 147 event_list[nevents].revents = 0;
146 148
147 ev->index = nevents; 149 ev->index = nevents;
148 nevents++; 150 nevents++;
149 151
150 } else { 152 } else {
151 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, 153 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
152 "poll add index: %d", e->index); 154 "poll add index: %i", e->index);
153 155
154 event_list[e->index].events |= event; 156 event_list[e->index].events |= (short) event;
155 ev->index = e->index; 157 ev->index = e->index;
156 } 158 }
157 159
158 return NGX_OK; 160 return NGX_OK;
159 } 161 }
160 162
161 163
162 static ngx_int_t 164 static ngx_int_t
163 ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags) 165 ngx_poll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
164 { 166 {
165 ngx_event_t *e; 167 ngx_event_t *e;
166 ngx_connection_t *c; 168 ngx_connection_t *c;
167 169
168 c = ev->data; 170 c = ev->data;
169 171
170 ev->active = 0; 172 ev->active = 0;
171 173
172 if (ev->index == NGX_INVALID_INDEX) { 174 if (ev->index == NGX_INVALID_INDEX) {
173 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, 175 ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
174 "poll event fd:%d ev:%d is already deleted", 176 "poll event fd:%d ev:%i is already deleted",
175 c->fd, event); 177 c->fd, event);
176 return NGX_OK; 178 return NGX_OK;
177 } 179 }
178 180
179 if (event == NGX_READ_EVENT) { 181 if (event == NGX_READ_EVENT) {
188 event = POLLOUT; 190 event = POLLOUT;
189 #endif 191 #endif
190 } 192 }
191 193
192 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, 194 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
193 "poll del event: fd:%d ev:%d", c->fd, event); 195 "poll del event: fd:%d ev:%i", c->fd, event);
194 196
195 if (e == NULL || e->index == NGX_INVALID_INDEX) { 197 if (e == NULL || e->index == NGX_INVALID_INDEX) {
196 nevents--; 198 nevents--;
197 199
198 if (ev->index < (u_int) nevents) { 200 if (ev->index < (ngx_uint_t) nevents) {
199 201
200 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, 202 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
201 "index: copy event %d to %d", nevents, ev->index); 203 "index: copy event %ui to %i", nevents, ev->index);
202 204
203 event_list[ev->index] = event_list[nevents]; 205 event_list[ev->index] = event_list[nevents];
204 206
205 c = ngx_cycle->files[event_list[nevents].fd]; 207 c = ngx_cycle->files[event_list[nevents].fd];
206 208
207 if (c->fd == -1) { 209 if (c->fd == -1) {
208 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, 210 ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
209 "unexpected last event"); 211 "unexpected last event");
210 212
211 } else { 213 } else {
212 if (c->read->index == (u_int) nevents) { 214 if (c->read->index == (ngx_uint_t) nevents) {
213 c->read->index = ev->index; 215 c->read->index = ev->index;
214 } 216 }
215 217
216 if (c->write->index == (u_int) nevents) { 218 if (c->write->index == (ngx_uint_t) nevents) {
217 c->write->index = ev->index; 219 c->write->index = ev->index;
218 } 220 }
219 } 221 }
220 } 222 }
221 223
222 } else { 224 } else {
223 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, 225 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
224 "poll del index: %d", e->index); 226 "poll del index: %i", e->index);
225 227
226 event_list[e->index].events &= ~event; 228 event_list[e->index].events &= (short) ~event;
227 } 229 }
228 230
229 ev->index = NGX_INVALID_INDEX; 231 ev->index = NGX_INVALID_INDEX;
230 232
231 return NGX_OK; 233 return NGX_OK;