[Patch] possible mutex starvation issue affects all nginx Linux versions.
itpp2012
nginx-forum at nginx.us
Mon Dec 2 12:15:52 UTC 2013
Here is a patch for a possible mutex starvation issue which affects all
nginx Linux versions.
Already solved for Windows since nginx 1.5.7.1 Caterpillar.
Can be reproduced when nginx reloads the config & worker holding mutex dies
or hangs.
Fixed by Vittorio Francesco Digilio, commercially sponsered solution by
ITPP.
target source mainline 1.5.8 - 30-11-2013.
src/event/ngx_event_accept.c, line 402 was correctly found (starvation fix)
but missed in:
src/event/ngx_event.c, line 259-260, 1 line added;
255 if (ngx_posted_accept_events) {
256 ngx_event_process_posted(cycle, &ngx_posted_accept_events);
257 }
258
259 if (ngx_accept_mutex_held) {
--+ ngx_accept_mutex_held=0;
260 ngx_shmtx_unlock(&ngx_accept_mutex);
261 }
262
263 if (delta) {
264 ngx_event_expire_timers();
265 }
Also applies to; src/os/win32/ngx_process_cycle.c
line 507-508, 3 lines added;
504 if (ngx_processes[n].handle != h) {
505 continue;
506 }
507
--+ if(*ngx_accept_mutex.lock==ngx_processes[n].pid) {
--+ *ngx_accept_mutex.lock=0;
--+ }
508 if (GetExitCodeProcess(h, &code) == 0) {
509 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
510 "GetExitCodeProcess(%P) failed",
511 ngx_processes[n].pid);
512 }
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,245121,245121#msg-245121
More information about the nginx
mailing list