Mercurial > hg > nginx
diff src/event/modules/ngx_rtsig_module.c @ 391:b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 14 Jul 2004 16:01:42 +0000 |
parents | 1471c6fb108a |
children | f209f3391020 |
line wrap: on
line diff
--- a/src/event/modules/ngx_rtsig_module.c +++ b/src/event/modules/ngx_rtsig_module.c @@ -23,6 +23,8 @@ int sigtimedwait(const sigset_t *set, si return -1; } +int ngx_linux_rtsig_max; + #endif @@ -45,6 +47,8 @@ static ngx_int_t ngx_rtsig_process_overf static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle); static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf); +static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, + void *post, void *data); static sigset_t set; @@ -55,7 +59,7 @@ static struct pollfd *overflow_list; static ngx_str_t rtsig_name = ngx_string("rtsig"); static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = { - ngx_conf_check_num_bounds, 2, 10 + ngx_check_ngx_overflow_threshold_bounds, 2, 10 }; @@ -644,6 +648,7 @@ static ngx_int_t ngx_rtsig_process_overf rev = c->read; if (rev->active + && !rev->closed && rev->event_handler && (overflow_list[i].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL))) @@ -663,6 +668,7 @@ static ngx_int_t ngx_rtsig_process_overf wev = c->write; if (wev->active + && !wev->closed && wev->event_handler && (overflow_list[i].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL))) @@ -686,39 +692,58 @@ static ngx_int_t ngx_rtsig_process_overf if (tested >= rtscf->overflow_test) { - /* - * Check the current rt queue length to prevent the new overflow. - * - * Learn the /proc/sys/kernel/rtsig-max value because - * it can be changed sisnce the last checking. - */ + if (ngx_linux_rtsig_max) { + + /* + * Check the current rt queue length to prevent + * the new overflow. + * + * Learn the /proc/sys/kernel/rtsig-max value because + * it can be changed sisnce the last checking. + */ - name[0] = CTL_KERN; - name[1] = KERN_RTSIGMAX; - len = sizeof(rtsig_max); - if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, - "sysctl(KERN_RTSIGMAX) failed"); - return NGX_ERROR; - } + name[0] = CTL_KERN; + name[1] = KERN_RTSIGMAX; + len = sizeof(rtsig_max); + if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, + "sysctl(KERN_RTSIGMAX) failed"); + return NGX_ERROR; + } - name[0] = CTL_KERN; - name[1] = KERN_RTSIGNR; - len = sizeof(rtsig_nr); - if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, - "sysctl(KERN_RTSIGNR) failed"); - return NGX_ERROR; - } + name[0] = CTL_KERN; + name[1] = KERN_RTSIGNR; + len = sizeof(rtsig_nr); + if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) + { + ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, + "sysctl(KERN_RTSIGNR) failed"); + return NGX_ERROR; + } + + /* + * drain rt signal queue if the /proc/sys/kernel/rtsig-nr + * is bigger than + * /proc/sys/kernel/rtsig-max / rtsig_overflow_threshold + */ - /* - * drain rt signal queue if the /proc/sys/kernel/rtsig-nr is bigger - * than "/proc/sys/kernel/rtsig-max / rtsig_overflow_threshold" - */ + if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) { + ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "rtsig queue state: %d/%d", + rtsig_nr, rtsig_max); + while (ngx_rtsig_process_events(cycle) == NGX_OK) { + /* void */ + } + } - if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) { - ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, - "rtsig queue state: %d/%d", rtsig_nr, rtsig_max); + } else { + + /* + * Linux has not KERN_RTSIGMAX since 2.6.6-mm2 + * so drain rt signal queue unconditionally + */ + while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ } } @@ -774,3 +799,18 @@ static char *ngx_rtsig_init_conf(ngx_cyc return NGX_CONF_OK; } + + +static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, + void *post, void *data) +{ + if (ngx_linux_rtsig_max) { + return ngx_conf_check_num_bounds(cf, post, data); + } + + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "\"rtsig_overflow_threshold\" is not supported " + "since Linux 2.6.6-mm2, ignored"); + + return NGX_CONF_OK; +}