comparison src/event/modules/ngx_rtsig_module.c @ 116:e38f51cd0905 NGINX_0_3_5

nginx 0.3.5 *) Bugfix: the segmentation fault may occurred if the IMAP/POP3 login was changed by authorization server; bug appeared in 0.2.2. *) Bugfix: the accept mutex did not work and all connections were handled by one process; bug appeared in 0.3.3. *) Bugfix: the timeout did not work if the "rtsig" method and the "timer_resolution" directive were used.
author Igor Sysoev <http://sysoev.ru>
date Fri, 21 Oct 2005 00:00:00 +0400
parents 408f195b3482
children d25a1d6034f1
comparison
equal deleted inserted replaced
115:45a230988aa5 116:e38f51cd0905
284 static ngx_int_t 284 static ngx_int_t
285 ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags) 285 ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
286 { 286 {
287 int signo; 287 int signo;
288 ngx_int_t instance; 288 ngx_int_t instance;
289 ngx_msec_t delta;
290 ngx_err_t err; 289 ngx_err_t err;
291 siginfo_t si; 290 siginfo_t si;
292 ngx_event_t *rev, *wev; 291 ngx_event_t *rev, *wev;
293 struct timespec ts, *tp; 292 struct timespec ts, *tp;
294 struct sigaction sa; 293 struct sigaction sa;
315 err = ngx_errno; 314 err = ngx_errno;
316 315
317 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, err, 316 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, err,
318 "rtsig signo:%d", signo); 317 "rtsig signo:%d", signo);
319 318
319 if (flags & NGX_UPDATE_TIME) {
320 ngx_time_update(0, 0);
321 }
322
320 if (err == NGX_EAGAIN) { 323 if (err == NGX_EAGAIN) {
321 324
322 if (timer == NGX_TIMER_INFINITE) { 325 /* timeout */
323 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, 326
324 "sigtimedwait() returned EAGAIN without timeout"); 327 if (timer != NGX_TIMER_INFINITE) {
325 return NGX_ERROR; 328 return NGX_AGAIN;
326 } 329 }
327 330
328 err = 0; 331 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
329 } 332 "sigtimedwait() returned EAGAIN without timeout");
330 333 return NGX_ERROR;
331 } else { 334 }
332 err = 0; 335
333 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, 336 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
334 "rtsig signo:%d fd:%d band:%04Xd", 337 cycle->log, err, "sigtimedwait() failed");
335 signo, si.si_fd, si.si_band); 338 return NGX_ERROR;
336 } 339 }
337 340
338 delta = ngx_current_msec; 341 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
339 342 "rtsig signo:%d fd:%d band:%04Xd",
343 signo, si.si_fd, si.si_band);
344
340 if (flags & NGX_UPDATE_TIME) { 345 if (flags & NGX_UPDATE_TIME) {
341 ngx_time_update(0, 0); 346 ngx_time_update(0, 0);
342 }
343
344 if (err) {
345 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
346 cycle->log, err, "sigtimedwait() failed");
347 return NGX_ERROR;
348 }
349
350 if (timer != NGX_TIMER_INFINITE) {
351 delta = ngx_current_msec - delta;
352
353 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
354 "rtsig timer: %M, delta: %M", timer, delta);
355 } 347 }
356 348
357 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); 349 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
358 350
359 if (signo == rtscf->signo || signo == rtscf->signo + 1) { 351 if (signo == rtscf->signo || signo == rtscf->signo + 1) {
398 if ((si.si_band & (POLLOUT|POLLHUP|POLLERR)) && wev->active) { 390 if ((si.si_band & (POLLOUT|POLLHUP|POLLERR)) && wev->active) {
399 wev->ready = 1; 391 wev->ready = 1;
400 wev->handler(wev); 392 wev->handler(wev);
401 } 393 }
402 394
395 return NGX_OK;
396
403 } else if (signo == SIGALRM) { 397 } else if (signo == SIGALRM) {
398
399 ngx_time_update(0, 0);
404 400
405 return NGX_OK; 401 return NGX_OK;
406 402
407 } else if (signo == SIGIO) { 403 } else if (signo == SIGIO) {
408 404
429 overflow_current = 0; 425 overflow_current = 0;
430 ngx_event_actions.process_events = ngx_rtsig_process_overflow; 426 ngx_event_actions.process_events = ngx_rtsig_process_overflow;
431 427
432 return NGX_ERROR; 428 return NGX_ERROR;
433 429
434 } else if (signo != -1) { 430 }
435 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, 431
436 "sigtimedwait() returned unexpected signal: %d", signo); 432 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
437 433 "sigtimedwait() returned unexpected signal: %d", signo);
438 return NGX_ERROR; 434
439 } 435 return NGX_ERROR;
440
441 if (signo != -1) {
442 return NGX_OK;
443 }
444
445 return NGX_AGAIN;
446 } 436 }
447 437
448 438
449 static ngx_int_t 439 static ngx_int_t
450 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer, 440 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer,