Welcome! Log In Create A New Profile

Advanced

[Patch] possible mutex starvation issue affects all nginx Linux versions.

December 02, 2013 07:15AM
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 }
SubjectAuthorPosted

[Patch] possible mutex starvation issue affects all nginx Linux versions.

itpp2012December 02, 2013 07:15AM

Re: [Patch] possible mutex starvation issue affects all nginx Linux versions.

Maxim DouninDecember 02, 2013 08:40AM

Re: [Patch] possible mutex starvation issue affects all nginx Linux versions.

itpp2012December 11, 2013 07:57AM

Re: [Patch] possible mutex starvation issue affects all nginx Linux versions.

Maxim DouninDecember 11, 2013 12:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready