comparison src/event/modules/ngx_rtsig_module.c @ 349:a958aa92f9a5

nginx-0.0.4-2004-06-09-20:36:55 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 09 Jun 2004 16:36:55 +0000
parents 68ff8000a974
children 7b96b7f8a6af
comparison
equal deleted inserted replaced
348:68ff8000a974 349:a958aa92f9a5
134 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c) 134 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c)
135 { 135 {
136 int signo; 136 int signo;
137 ngx_rtsig_conf_t *rtscf; 137 ngx_rtsig_conf_t *rtscf;
138 138
139 if (c->read->accept && c->read->disabled) {
140 if (fcntl(c->fd, F_SETOWN, ngx_pid) == -1) {
141 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
142 "fcntl(F_SETOWN) failed");
143 return NGX_ERROR;
144 }
145
146 c->read->active = 1;
147 c->read->disabled = 0;
148 }
149
139 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); 150 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
140 151
141 signo = rtscf->signo + c->read->instance; 152 signo = rtscf->signo + c->read->instance;
142 153
143 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 154 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
179 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags) 190 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
180 { 191 {
181 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 192 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
182 "rtsig del connection: fd:%d", c->fd); 193 "rtsig del connection: fd:%d", c->fd);
183 194
184 if (!(flags & NGX_CLOSE_EVENT)) { 195 if ((flags & NGX_DISABLE_EVENT) && c->read->accept) {
185 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK) == -1) { 196 c->read->active = 0;
186 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, 197 c->read->disabled = 0;
187 "fcntl(O_RDWR|O_NONBLOCK) failed"); 198 return NGX_OK;
188 return NGX_ERROR; 199 }
189 } 200
201 if (flags & NGX_CLOSE_EVENT) {
202 c->read->active = 0;
203 c->write->active = 0;
204 return NGX_OK;
205 }
206
207 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK) == -1) {
208 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
209 "fcntl(O_RDWR|O_NONBLOCK) failed");
210 return NGX_ERROR;
190 } 211 }
191 212
192 c->read->active = 0; 213 c->read->active = 0;
193 c->write->active = 0; 214 c->write->active = 0;
194 215
442 463
443 if (!ngx_threaded) { 464 if (!ngx_threaded) {
444 ngx_event_process_posted(cycle); 465 ngx_event_process_posted(cycle);
445 } 466 }
446 467
447 return NGX_OK; 468 if (signo == -1) {
469 return NGX_AGAIN;
470 } else {
471 return NGX_OK;
472 }
448 } 473 }
449 474
450 475
451 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)
452 { 477 {
529 /* 554 /*
530 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr 555 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr
531 * is bigger then "/proc/sys/kernel/rtsig-max / 4" 556 * is bigger then "/proc/sys/kernel/rtsig-max / 4"
532 */ 557 */
533 558
534 while (rtsig_max / 4 < rtsig_nr) { 559 if (rtsig_max / 4 < rtsig_nr) {
535 ngx_rtsig_process_events(cycle); 560 while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ }
536 rtsig_nr--;
537 } 561 }
538 } 562 }
539 } 563 }
540 564
541 if (!ngx_threaded) { 565 if (!ngx_threaded) {