Mercurial > hg > nginx-quic
comparison src/event/modules/ngx_epoll_module.c @ 557:ecd9c160f25b release-0.3.0
nginx-0.3.0-RELEASE import
*) Change: the 10-days live time limit of worker process was
eliminated. The limit was introduced because of millisecond timers
overflow.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 07 Oct 2005 13:30:52 +0000 |
parents | b09ee85d0ac8 |
children | c1f965ef9718 |
comparison
equal
deleted
inserted
replaced
556:21a706ff4e1f | 557:ecd9c160f25b |
---|---|
385 ngx_epoll_process_events(ngx_cycle_t *cycle) | 385 ngx_epoll_process_events(ngx_cycle_t *cycle) |
386 { | 386 { |
387 int events; | 387 int events; |
388 uint32_t revents; | 388 uint32_t revents; |
389 ngx_int_t instance, i; | 389 ngx_int_t instance, i; |
390 ngx_uint_t lock, accept_lock, expire; | 390 ngx_uint_t lock, accept_lock; |
391 ngx_err_t err; | 391 ngx_err_t err; |
392 ngx_log_t *log; | 392 ngx_log_t *log; |
393 ngx_msec_t timer; | 393 ngx_msec_t timer, delta; |
394 ngx_event_t *rev, *wev; | 394 ngx_event_t *rev, *wev; |
395 struct timeval tv; | 395 struct timeval tv; |
396 ngx_connection_t *c; | 396 ngx_connection_t *c; |
397 ngx_epoch_msec_t delta; | 397 |
398 | 398 timer = ngx_event_find_timer(); |
399 for ( ;; ) { | |
400 timer = ngx_event_find_timer(); | |
401 | 399 |
402 #if (NGX_THREADS) | 400 #if (NGX_THREADS) |
403 | 401 |
404 if (timer == NGX_TIMER_ERROR) { | 402 if (timer == NGX_TIMER_ERROR) { |
405 return NGX_ERROR; | 403 return NGX_ERROR; |
406 } | 404 } |
407 | 405 |
408 if (timer == NGX_TIMER_INFINITE || timer > 500) { | 406 if (timer == NGX_TIMER_INFINITE || timer > 500) { |
409 timer = 500; | 407 timer = 500; |
410 break; | 408 break; |
411 } | 409 } |
412 | 410 |
413 #endif | 411 #endif |
414 | 412 |
415 if (timer != 0) { | |
416 break; | |
417 } | |
418 | |
419 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | |
420 "epoll expired timer"); | |
421 | |
422 ngx_event_expire_timers((ngx_msec_t) | |
423 (ngx_elapsed_msec - ngx_old_elapsed_msec)); | |
424 | |
425 if (ngx_posted_events && ngx_threaded) { | |
426 ngx_wakeup_worker_thread(cycle); | |
427 } | |
428 } | |
429 | |
430 /* NGX_TIMER_INFINITE == INFTIM */ | 413 /* NGX_TIMER_INFINITE == INFTIM */ |
431 | 414 |
432 if (timer == NGX_TIMER_INFINITE) { | |
433 expire = 0; | |
434 | |
435 } else { | |
436 expire = 1; | |
437 } | |
438 | |
439 ngx_old_elapsed_msec = ngx_elapsed_msec; | |
440 accept_lock = 0; | 415 accept_lock = 0; |
441 | 416 |
442 if (ngx_accept_mutex) { | 417 if (ngx_accept_mutex) { |
443 if (ngx_accept_disabled > 0) { | 418 if (ngx_accept_disabled > 0) { |
444 ngx_accept_disabled--; | 419 ngx_accept_disabled--; |
453 | 428 |
454 } else if (timer == NGX_TIMER_INFINITE | 429 } else if (timer == NGX_TIMER_INFINITE |
455 || timer > ngx_accept_mutex_delay) | 430 || timer > ngx_accept_mutex_delay) |
456 { | 431 { |
457 timer = ngx_accept_mutex_delay; | 432 timer = ngx_accept_mutex_delay; |
458 expire = 0; | |
459 } | 433 } |
460 } | 434 } |
461 } | 435 } |
462 | 436 |
463 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | 437 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
464 "epoll timer: %d", timer); | 438 "epoll timer: %M", timer); |
465 | 439 |
466 events = epoll_wait(ep, event_list, nevents, timer); | 440 events = epoll_wait(ep, event_list, nevents, timer); |
467 | 441 |
468 if (events == -1) { | 442 if (events == -1) { |
469 err = ngx_errno; | 443 err = ngx_errno; |
472 } | 446 } |
473 | 447 |
474 ngx_gettimeofday(&tv); | 448 ngx_gettimeofday(&tv); |
475 ngx_time_update(tv.tv_sec); | 449 ngx_time_update(tv.tv_sec); |
476 | 450 |
477 delta = ngx_elapsed_msec; | 451 delta = ngx_current_time; |
478 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 | 452 ngx_current_time = (ngx_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; |
479 + tv.tv_usec / 1000 - ngx_start_msec; | |
480 | 453 |
481 if (timer != NGX_TIMER_INFINITE) { | 454 if (timer != NGX_TIMER_INFINITE) { |
482 delta = ngx_elapsed_msec - delta; | 455 delta = ngx_current_time - delta; |
483 | 456 |
484 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | 457 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
485 "epoll timer: %d, delta: %d", timer, (int) delta); | 458 "epoll timer: %M, delta: %M", timer, delta); |
486 } else { | 459 } else { |
487 if (events == 0) { | 460 if (events == 0) { |
488 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | 461 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
489 "epoll_wait() returned no events without timeout"); | 462 "epoll_wait() returned no events without timeout"); |
490 ngx_accept_mutex_unlock(); | 463 ngx_accept_mutex_unlock(); |
643 | 616 |
644 if (lock) { | 617 if (lock) { |
645 ngx_mutex_unlock(ngx_posted_events_mutex); | 618 ngx_mutex_unlock(ngx_posted_events_mutex); |
646 } | 619 } |
647 | 620 |
648 if (expire && delta) { | 621 ngx_event_expire_timers(); |
649 ngx_event_expire_timers((ngx_msec_t) delta); | |
650 } | |
651 | 622 |
652 if (ngx_posted_events) { | 623 if (ngx_posted_events) { |
653 if (ngx_threaded) { | 624 if (ngx_threaded) { |
654 ngx_wakeup_worker_thread(cycle); | 625 ngx_wakeup_worker_thread(cycle); |
655 | 626 |