comparison src/event/modules/ngx_rtsig_module.c @ 326:f70f2f565fe0 NGINX_0_5_33

nginx 0.5.33 *) Change: now by default the "echo" SSI command uses entity encoding. *) Feature: the "encoding" parameter in the "echo" SSI command. *) Change: mail proxy was split on three modules: pop3, imap and smtp. *) Feature: the --without-mail_pop3_module, --without-mail_imap_module, and --without-mail_smtp_module configuration parameters. *) Feature: the "smtp_greeting_delay" and "smtp_client_buffer" directives of the ngx_mail_smtp_module. *) Feature: the "server_name" and "valid_referers" directives support regular expressions. *) Feature: the "server_name", "map", and "valid_referers" directives support the "www.example.*" wildcards. *) Bugfix: sub_filter did not work with empty substitution. *) Bugfix: in sub_filter parsing. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used. *) Bugfix: nginx supported low case only "close" and "keep-alive" values in the "Connection" request header line; bug appeared in 0.5.32. *) Bugfix: nginx could not start on Solaris if the shared PCRE library located in non-standard place was used.
author Igor Sysoev <http://sysoev.ru>
date Wed, 07 Nov 2007 00:00:00 +0300
parents df17fbafec8f
children 2eea67ed0bc2
comparison
equal deleted inserted replaced
325:5bb1b28ddeaa 326:f70f2f565fe0
27 27
28 #endif 28 #endif
29 29
30 30
31 typedef struct { 31 typedef struct {
32 int signo; 32 ngx_uint_t signo;
33 ngx_int_t overflow_events; 33 ngx_uint_t overflow_events;
34 ngx_int_t overflow_test; 34 ngx_uint_t overflow_test;
35 ngx_int_t overflow_threshold; 35 ngx_uint_t overflow_threshold;
36 } ngx_rtsig_conf_t; 36 } ngx_rtsig_conf_t;
37 37
38 38
39 extern ngx_event_module_t ngx_poll_module_ctx; 39 extern ngx_event_module_t ngx_poll_module_ctx;
40 40
41 static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer); 41 static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer);
42 static void ngx_rtsig_done(ngx_cycle_t *cycle); 42 static void ngx_rtsig_done(ngx_cycle_t *cycle);
43 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c); 43 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c);
44 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags); 44 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c,
45 ngx_uint_t flags);
45 static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle, 46 static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle,
46 ngx_msec_t timer, ngx_uint_t flags); 47 ngx_msec_t timer, ngx_uint_t flags);
47 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle, 48 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle,
48 ngx_msec_t timer, ngx_uint_t flags); 49 ngx_msec_t timer, ngx_uint_t flags);
49 50
141 ngx_rtsig_conf_t *rtscf; 142 ngx_rtsig_conf_t *rtscf;
142 143
143 rtscf = ngx_event_get_conf(cycle->conf_ctx, ngx_rtsig_module); 144 rtscf = ngx_event_get_conf(cycle->conf_ctx, ngx_rtsig_module);
144 145
145 sigemptyset(&set); 146 sigemptyset(&set);
146 sigaddset(&set, rtscf->signo); 147 sigaddset(&set, (int) rtscf->signo);
147 sigaddset(&set, rtscf->signo + 1); 148 sigaddset(&set, (int) rtscf->signo + 1);
148 sigaddset(&set, SIGIO); 149 sigaddset(&set, SIGIO);
149 sigaddset(&set, SIGALRM); 150 sigaddset(&set, SIGALRM);
150 151
151 if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) { 152 if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
152 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 153 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
186 187
187 188
188 static ngx_int_t 189 static ngx_int_t
189 ngx_rtsig_add_connection(ngx_connection_t *c) 190 ngx_rtsig_add_connection(ngx_connection_t *c)
190 { 191 {
191 int signo; 192 ngx_uint_t signo;
192 ngx_rtsig_conf_t *rtscf; 193 ngx_rtsig_conf_t *rtscf;
193 194
194 if (c->read->accept && c->read->disabled) { 195 if (c->read->accept && c->read->disabled) {
195 196
196 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 197 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
209 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); 210 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
210 211
211 signo = rtscf->signo + c->read->instance; 212 signo = rtscf->signo + c->read->instance;
212 213
213 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 214 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
214 "rtsig add connection: fd:%d signo:%d", c->fd, signo); 215 "rtsig add connection: fd:%d signo:%ui", c->fd, signo);
215 216
216 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) { 217 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) {
217 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, 218 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
218 "fcntl(O_RDWR|O_NONBLOCK|O_ASYNC) failed"); 219 "fcntl(O_RDWR|O_NONBLOCK|O_ASYNC) failed");
219 return NGX_ERROR; 220 return NGX_ERROR;
220 } 221 }
221 222
222 if (fcntl(c->fd, F_SETSIG, signo) == -1) { 223 if (fcntl(c->fd, F_SETSIG, (int) signo) == -1) {
223 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, 224 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
224 "fcntl(F_SETSIG) failed"); 225 "fcntl(F_SETSIG) failed");
225 return NGX_ERROR; 226 return NGX_ERROR;
226 } 227 }
227 228
245 return NGX_OK; 246 return NGX_OK;
246 } 247 }
247 248
248 249
249 static ngx_int_t 250 static ngx_int_t
250 ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags) 251 ngx_rtsig_del_connection(ngx_connection_t *c, ngx_uint_t flags)
251 { 252 {
252 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 253 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
253 "rtsig del connection: fd:%d", c->fd); 254 "rtsig del connection: fd:%d", c->fd);
254 255
255 if ((flags & NGX_DISABLE_EVENT) && c->read->accept) { 256 if ((flags & NGX_DISABLE_EVENT) && c->read->accept) {
346 ngx_time_update(0, 0); 347 ngx_time_update(0, 0);
347 } 348 }
348 349
349 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); 350 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
350 351
351 if (signo == rtscf->signo || signo == rtscf->signo + 1) { 352 if (signo == (int) rtscf->signo || signo == (int) rtscf->signo + 1) {
352 353
353 if (overflow && (ngx_uint_t) si.si_fd > overflow_current) { 354 if (overflow && (ngx_uint_t) si.si_fd > overflow_current) {
354 return NGX_OK; 355 return NGX_OK;
355 } 356 }
356 357
361 /* the stale event */ 362 /* the stale event */
362 363
363 return NGX_OK; 364 return NGX_OK;
364 } 365 }
365 366
366 instance = signo - rtscf->signo; 367 instance = signo - (int) rtscf->signo;
367 368
368 rev = c->read; 369 rev = c->read;
369 370
370 if (rev->instance != instance) { 371 if (rev->instance != instance) {
371 372
457 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer, 458 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer,
458 ngx_uint_t flags) 459 ngx_uint_t flags)
459 { 460 {
460 int name[2], rtsig_max, rtsig_nr, events, ready; 461 int name[2], rtsig_max, rtsig_nr, events, ready;
461 size_t len; 462 size_t len;
462 ngx_int_t tested, n, i;
463 ngx_err_t err; 463 ngx_err_t err;
464 ngx_uint_t tested, n, i;
464 ngx_event_t *rev, *wev, **queue; 465 ngx_event_t *rev, *wev, **queue;
465 ngx_connection_t *c; 466 ngx_connection_t *c;
466 ngx_rtsig_conf_t *rtscf; 467 ngx_rtsig_conf_t *rtscf;
467 468
468 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, 469 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
636 * drain the rt signal queue if the /"proc/sys/kernel/rtsig-nr" 637 * drain the rt signal queue if the /"proc/sys/kernel/rtsig-nr"
637 * is bigger than 638 * is bigger than
638 * "/proc/sys/kernel/rtsig-max" / "rtsig_overflow_threshold" 639 * "/proc/sys/kernel/rtsig-max" / "rtsig_overflow_threshold"
639 */ 640 */
640 641
641 if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) { 642 if (rtsig_max / (int) rtscf->overflow_threshold < rtsig_nr) {
642 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, 643 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
643 "rtsig queue state: %d/%d", 644 "rtsig queue state: %d/%d",
644 rtsig_nr, rtsig_max); 645 rtsig_nr, rtsig_max);
645 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) 646 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK)
646 { 647 {
701 ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf) 702 ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
702 { 703 {
703 ngx_rtsig_conf_t *rtscf = conf; 704 ngx_rtsig_conf_t *rtscf = conf;
704 705
705 /* LinuxThreads use the first 3 RT signals */ 706 /* LinuxThreads use the first 3 RT signals */
706 ngx_conf_init_value(rtscf->signo, SIGRTMIN + 10); 707 ngx_conf_init_uint_value(rtscf->signo, SIGRTMIN + 10);
707 708
708 ngx_conf_init_value(rtscf->overflow_events, 16); 709 ngx_conf_init_uint_value(rtscf->overflow_events, 16);
709 ngx_conf_init_value(rtscf->overflow_test, 32); 710 ngx_conf_init_uint_value(rtscf->overflow_test, 32);
710 ngx_conf_init_value(rtscf->overflow_threshold, 10); 711 ngx_conf_init_uint_value(rtscf->overflow_threshold, 10);
711 712
712 return NGX_CONF_OK; 713 return NGX_CONF_OK;
713 } 714 }
714 715
715 716
716 static char * 717 static char *
717 ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, 718 ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, void *post, void *data)
718 void *post, void *data)
719 { 719 {
720 if (ngx_linux_rtsig_max) { 720 if (ngx_linux_rtsig_max) {
721 return ngx_conf_check_num_bounds(cf, post, data); 721 return ngx_conf_check_num_bounds(cf, post, data);
722 } 722 }
723 723