comparison src/event/modules/ngx_kqueue_module.c @ 4:4b2dafa26fe2 NGINX_0_1_2

nginx 0.1.2 *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; bug appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; bug appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
author Igor Sysoev <http://sysoev.ru>
date Thu, 21 Oct 2004 00:00:00 +0400
parents f0b350454894
children 46833bd150cb
comparison
equal deleted inserted replaced
3:8beaf7b3241f 4:4b2dafa26fe2
192 #if (HAVE_CLEAR_EVENT) 192 #if (HAVE_CLEAR_EVENT)
193 |NGX_USE_CLEAR_EVENT 193 |NGX_USE_CLEAR_EVENT
194 #else 194 #else
195 |NGX_USE_LEVEL_EVENT 195 |NGX_USE_LEVEL_EVENT
196 #endif 196 #endif
197 #if (HAVE_LOWAT_EVENT) 197 #if (NGX_HAVE_LOWAT_EVENT)
198 |NGX_HAVE_LOWAT_EVENT 198 |NGX_USE_LOWAT_EVENT
199 #endif 199 #endif
200 |NGX_HAVE_KQUEUE_EVENT; 200 |NGX_USE_KQUEUE_EVENT;
201 201
202 return NGX_OK; 202 return NGX_OK;
203 } 203 }
204 204
205 205
243 243
244 if (ngx_mutex_lock(list_mutex) == NGX_ERROR) { 244 if (ngx_mutex_lock(list_mutex) == NGX_ERROR) {
245 return NGX_ERROR; 245 return NGX_ERROR;
246 } 246 }
247 247
248 #if 1
249
248 if (nchanges > 0 250 if (nchanges > 0
249 && ev->index < (u_int) nchanges 251 && ev->index < (u_int) nchanges
250 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) 252 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
251 == (uintptr_t) ev) 253 == (uintptr_t) ev)
252 { 254 {
260 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, 262 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
261 "kevent activated: %d: ft:%d", 263 "kevent activated: %d: ft:%d",
262 ngx_event_ident(ev->data), event); 264 ngx_event_ident(ev->data), event);
263 265
264 if (ev->index < (u_int) --nchanges) { 266 if (ev->index < (u_int) --nchanges) {
265 e = (ngx_event_t *) change_list[nchanges].udata; 267 e = (ngx_event_t *)
268 ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
266 change_list[ev->index] = change_list[nchanges]; 269 change_list[ev->index] = change_list[nchanges];
267 e->index = ev->index; 270 e->index = ev->index;
268 } 271 }
269 272
270 ngx_mutex_unlock(list_mutex); 273 ngx_mutex_unlock(list_mutex);
280 ngx_mutex_unlock(list_mutex); 283 ngx_mutex_unlock(list_mutex);
281 284
282 return NGX_ERROR; 285 return NGX_ERROR;
283 } 286 }
284 287
288 #endif
289
285 rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags); 290 rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags);
286 291
287 ngx_mutex_unlock(list_mutex); 292 ngx_mutex_unlock(list_mutex);
288 293
289 return rc; 294 return rc;
299 ev->disabled = 0; 304 ev->disabled = 0;
300 305
301 if (ngx_mutex_lock(list_mutex) == NGX_ERROR) { 306 if (ngx_mutex_lock(list_mutex) == NGX_ERROR) {
302 return NGX_ERROR; 307 return NGX_ERROR;
303 } 308 }
309
310 #if 1
304 311
305 if (nchanges > 0 312 if (nchanges > 0
306 && ev->index < (u_int) nchanges 313 && ev->index < (u_int) nchanges
307 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) 314 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
308 == (uintptr_t) ev) 315 == (uintptr_t) ev)
312 ngx_event_ident(ev->data), event); 319 ngx_event_ident(ev->data), event);
313 320
314 /* if the event is still not passed to a kernel we will not pass it */ 321 /* if the event is still not passed to a kernel we will not pass it */
315 322
316 if (ev->index < (u_int) --nchanges) { 323 if (ev->index < (u_int) --nchanges) {
317 e = (ngx_event_t *) change_list[nchanges].udata; 324 e = (ngx_event_t *)
325 ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
318 change_list[ev->index] = change_list[nchanges]; 326 change_list[ev->index] = change_list[nchanges];
319 e->index = ev->index; 327 e->index = ev->index;
320 } 328 }
321 329
322 ngx_mutex_unlock(list_mutex); 330 ngx_mutex_unlock(list_mutex);
323 331
324 return NGX_OK; 332 return NGX_OK;
325 } 333 }
334
335 #endif
326 336
327 /* 337 /*
328 * when the file descriptor is closed the kqueue automatically deletes 338 * when the file descriptor is closed the kqueue automatically deletes
329 * its filters so we do not need to delete explicity the event 339 * its filters so we do not need to delete explicity the event
330 * before the closing the file descriptor. 340 * before the closing the file descriptor.
391 #endif 401 #endif
392 ; 402 ;
393 kev->data = 0; 403 kev->data = 0;
394 404
395 } else { 405 } else {
396 #if (HAVE_LOWAT_EVENT) 406 #if (NGX_HAVE_LOWAT_EVENT)
397 if (flags & NGX_LOWAT_EVENT) { 407 if (flags & NGX_LOWAT_EVENT) {
398 kev->fflags = NOTE_LOWAT; 408 kev->fflags = NOTE_LOWAT;
399 kev->data = ev->available; 409 kev->data = ev->available;
400 410
401 } else { 411 } else {