aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-06-02 13:57:59 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-06-02 13:57:59 +0000
commita119584e66692489eb60e505ded1c33b32ba12c6 (patch)
tree66be3f13829a1cc35a6fdbb1c96f8c2cec53bf81
parent5b26bec9e8b3e7659e3aaa161b491c34ecdff036 (diff)
downloadnginx-a119584e66692489eb60e505ded1c33b32ba12c6.tar.gz
nginx-a119584e66692489eb60e505ded1c33b32ba12c6.zip
test that zone has the same addresses in different processes
-rw-r--r--src/core/ngx_cycle.c20
-rw-r--r--src/core/ngx_slab.h1
2 files changed, 16 insertions, 5 deletions
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index fc65765b0..47d5f56d8 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -463,11 +463,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
goto failed;
}
- if (!shm_zone[i].shm.exists) {
-
- if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
- goto failed;
- }
+ if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
+ goto failed;
}
if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
@@ -885,8 +882,21 @@ ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn)
sp = (ngx_slab_pool_t *) zn->shm.addr;
+ if (zn->shm.exists) {
+
+ if (sp == sp->addr) {
+ return NGX_OK;
+ }
+
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "shared zone \"%V\" has no equal addresses: %p vs %p",
+ &zn->shm.name, sp->addr, sp);
+ return NGX_ERROR;
+ }
+
sp->end = zn->shm.addr + zn->shm.size;
sp->min_shift = 3;
+ sp->addr = zn->shm.addr;
#if (NGX_HAVE_ATOMIC_OPS)
diff --git a/src/core/ngx_slab.h b/src/core/ngx_slab.h
index 89c4687f6..291e1b51e 100644
--- a/src/core/ngx_slab.h
+++ b/src/core/ngx_slab.h
@@ -39,6 +39,7 @@ typedef struct {
u_char zero;
void *data;
+ void *addr;
} ngx_slab_pool_t;