# HG changeset patch # User Maxim Dounin # Date 1355163452 0 # Node ID bbcaeccbd92889692ac10234f38072c087a619e9 # Parent 2e4e4084b562ca2372c21eecbb3a34bf58356c28 Merge of r4933, r4933: shared memory fixes. *) Fixed location of debug message in ngx_shmtx_lock(). *) Core: don't reuse shared memory zone that changed ownership (ticket #210). nginx doesn't allow the same shared memory zone to be used for different purposes, but failed to check this on reconfiguration. If a shared memory zone was used for another purpose in the new configuration, nginx attempted to reuse it and crashed. diff -r 2e4e4084b562 -r bbcaeccbd928 src/core/ngx_cycle.c --- a/src/core/ngx_cycle.c Mon Dec 10 18:04:54 2012 +0000 +++ b/src/core/ngx_cycle.c Mon Dec 10 18:17:32 2012 +0000 @@ -447,7 +447,9 @@ continue; } - if (shm_zone[i].shm.size == oshm_zone[n].shm.size) { + if (shm_zone[i].tag == oshm_zone[n].tag + && shm_zone[i].shm.size == oshm_zone[n].shm.size) + { shm_zone[i].shm.addr = oshm_zone[n].shm.addr; if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data) diff -r 2e4e4084b562 -r bbcaeccbd928 src/core/ngx_shmtx.c --- a/src/core/ngx_shmtx.c Mon Dec 10 18:04:54 2012 +0000 +++ b/src/core/ngx_shmtx.c Mon Dec 10 18:17:32 2012 +0000 @@ -117,10 +117,10 @@ "sem_wait() failed while waiting on shmtx"); break; } + } - ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, - "shmtx awoke"); - } + ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, + "shmtx awoke"); continue; }