]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4933, r4933: shared memory fixes.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 10 Dec 2012 18:17:32 +0000 (18:17 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 10 Dec 2012 18:17:32 +0000 (18:17 +0000)
*) 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.

src/core/ngx_cycle.c
src/core/ngx_shmtx.c

index f15372990edafd61caaa65608b6e5e7ed04b475f..e8b1559212bc22ce3102f6dbfb5142177842b411 100644 (file)
@@ -447,7 +447,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
                 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)
index 6cf7af58ae9b50893de47eb847e23f5d039a4d8c..a62999f33937b63f4504d2adcd4a84dcf0b5bdbe 100644 (file)
@@ -117,11 +117,11 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx)
                                   "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;
         }