Mercurial > hg > nginx
comparison src/event/modules/ngx_poll_module.c @ 323:ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 Apr 2004 18:54:33 +0000 |
parents | 56496082668b |
children | e0f3f238db09 |
comparison
equal
deleted
inserted
replaced
322:ab2f8c9a2a45 | 323:ba876b26b76d |
---|---|
302 } | 302 } |
303 | 303 |
304 ngx_old_elapsed_msec = ngx_elapsed_msec; | 304 ngx_old_elapsed_msec = ngx_elapsed_msec; |
305 | 305 |
306 #if (NGX_DEBUG0) | 306 #if (NGX_DEBUG0) |
307 for (i = 0; i < nevents; i++) { | 307 if (cycle->log->log_level & NGX_LOG_DEBUG_ALL) { |
308 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | 308 for (i = 0; i < nevents; i++) { |
309 "poll: %d: fd:%d ev:%04X", | 309 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
310 i, event_list[i].fd, event_list[i].events); | 310 "poll: %d: fd:%d ev:%04X", |
311 i, event_list[i].fd, event_list[i].events); | |
312 } | |
311 } | 313 } |
312 #endif | 314 #endif |
313 | 315 |
314 if (ngx_accept_mutex) { | 316 if (ngx_accept_mutex) { |
315 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { | 317 if (ngx_accept_disabled > 0) { |
316 return NGX_ERROR; | 318 ngx_accept_disabled--; |
317 } | 319 |
318 | 320 } else { |
319 if (ngx_accept_mutex_held == 0 | 321 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { |
320 && (timer == NGX_TIMER_INFINITE || timer > ngx_accept_mutex_delay)) | 322 return NGX_ERROR; |
321 { | 323 } |
322 timer = ngx_accept_mutex_delay; | 324 |
323 expire = 0; | 325 if (ngx_accept_mutex_held == 0 |
326 && (timer == NGX_TIMER_INFINITE | |
327 || timer > ngx_accept_mutex_delay)) | |
328 { | |
329 timer = ngx_accept_mutex_delay; | |
330 expire = 0; | |
331 } | |
324 } | 332 } |
325 } | 333 } |
326 | 334 |
327 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "poll timer: %d", timer); | 335 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "poll timer: %d", timer); |
328 | 336 |
541 | 549 |
542 ngx_mutex_unlock(ngx_posted_events_mutex); | 550 ngx_mutex_unlock(ngx_posted_events_mutex); |
543 | 551 |
544 ev->event_handler(ev); | 552 ev->event_handler(ev); |
545 | 553 |
554 if (ngx_accept_disabled > 0) { | |
555 lock = 0; | |
556 break; | |
557 } | |
558 | |
546 ev = ev->next; | 559 ev = ev->next; |
547 | 560 |
548 if (ev == NULL) { | 561 if (ev == NULL) { |
549 lock = 0; | 562 lock = 0; |
550 break; | 563 break; |
555 return NGX_ERROR; | 568 return NGX_ERROR; |
556 } | 569 } |
557 | 570 |
558 } | 571 } |
559 | 572 |
573 ngx_accept_mutex_unlock(); | |
574 accept_events = NULL; | |
575 | |
560 if (lock) { | 576 if (lock) { |
561 ngx_mutex_unlock(ngx_posted_events_mutex); | 577 ngx_mutex_unlock(ngx_posted_events_mutex); |
562 } | 578 } |
563 | 579 |
564 ngx_accept_mutex_unlock(); | |
565 accept_events = NULL; | |
566 | |
567 if (ready != 0) { | 580 if (ready != 0) { |
568 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "poll ready != events"); | 581 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "poll ready != events"); |
569 } | 582 } |
570 | 583 |
571 if (expire && delta) { | 584 if (expire && delta) { |