comparison src/event/modules/ngx_rtsig_module.c @ 350:7b96b7f8a6af

nginx-0.0.4-2004-06-10-00:03:54 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 09 Jun 2004 20:03:54 +0000
parents a958aa92f9a5
children af4c6b45a687
comparison
equal deleted inserted replaced
349:a958aa92f9a5 350:7b96b7f8a6af
474 474
475 475
476 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle) 476 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
477 { 477 {
478 int name[2], len, rtsig_max, rtsig_nr; 478 int name[2], len, rtsig_max, rtsig_nr;
479 ngx_uint_t i; 479 ngx_uint_t i, n;
480 ngx_connection_t *c; 480 ngx_connection_t *c;
481 481
482 /* TODO: old cylces */ 482 /* TODO: old cylces */
483 483
484 n = 0;
484 c = cycle->connections; 485 c = cycle->connections;
485 for (current = 0; current < cycle->connection_n; current++) { 486 for (current = 0; current < cycle->connection_n; current++) {
486 487
487 i = current; 488 i = current;
488 489
489 if (c[i].fd == -1) { 490 if (c[i].fd == -1) {
490 continue; 491 continue;
491 } 492 }
492 493
493 if (c[i].read->active && c[i].read->event_handler) { 494 if (c[i].read->active && c[i].read->event_handler) {
495 n++;
494 c[i].read->ready = 1; 496 c[i].read->ready = 1;
495 497
496 if (!ngx_threaded) { 498 if (!ngx_threaded) {
497 c[i].read->event_handler(c[i].read); 499 c[i].read->event_handler(c[i].read);
498 500
506 ngx_mutex_unlock(ngx_posted_events_mutex); 508 ngx_mutex_unlock(ngx_posted_events_mutex);
507 } 509 }
508 } 510 }
509 511
510 if (c[i].write->active && c[i].write->event_handler) { 512 if (c[i].write->active && c[i].write->event_handler) {
513 n++;
511 c[i].write->ready = 1; 514 c[i].write->ready = 1;
512 515
513 if (!ngx_threaded) { 516 if (!ngx_threaded) {
514 c[i].write->event_handler(c[i].write); 517 c[i].write->event_handler(c[i].write);
515 518
522 525
523 ngx_mutex_unlock(ngx_posted_events_mutex); 526 ngx_mutex_unlock(ngx_posted_events_mutex);
524 } 527 }
525 } 528 }
526 529
527 if (i && (i % 100 == 0)) { 530 if (n && (n % 100 == 0)) {
528 531
529 /* 532 /*
530 * Check the current rt queue length to prevent the new overflow. 533 * Check the current rt queue length to prevent the new overflow.
531 * 534 *
532 * Learn the /proc/sys/kernel/rtsig-max value because 535 * Learn the /proc/sys/kernel/rtsig-max value because
533 * it can be changed sisnce the last checking 536 * it can be changed sisnce the last checking.
534 */ 537 */
535 538
536 name[0] = CTL_KERN; 539 name[0] = CTL_KERN;
537 name[1] = KERN_RTSIGMAX; 540 name[1] = KERN_RTSIGMAX;
538 len = sizeof(rtsig_max); 541 len = sizeof(rtsig_max);
551 return NGX_ERROR; 554 return NGX_ERROR;
552 } 555 }
553 556
554 /* 557 /*
555 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr 558 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr
556 * is bigger then "/proc/sys/kernel/rtsig-max / 4" 559 * is bigger than "/proc/sys/kernel/rtsig-max / 4"
557 */ 560 */
558 561
559 if (rtsig_max / 4 < rtsig_nr) { 562 if (rtsig_max / 4 < rtsig_nr) {
563 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
564 "rtsig queue state: %d/%d", rtsig_nr, rtsig_max);
560 while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ } 565 while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ }
561 } 566 }
562 } 567 }
563 } 568 }
564 569