Mercurial > hg > nginx
comparison src/http/modules/ngx_http_limit_zone_module.c @ 993:1b9a4d92173f
pass the inherited shm_zone data
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 09 Jan 2007 15:59:20 +0000 |
parents | 14e68f471d02 |
children | 5900ec20604a |
comparison
equal
deleted
inserted
replaced
992:3f2e60adf4ef | 993:1b9a4d92173f |
---|---|
245 ngx_shmtx_unlock(&shpool->mutex); | 245 ngx_shmtx_unlock(&shpool->mutex); |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 static ngx_int_t | 249 static ngx_int_t |
250 ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone) | 250 ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone, void *data) |
251 { | 251 { |
252 ngx_http_limit_zone_ctx_t *octx = data; | |
253 | |
252 ngx_slab_pool_t *shpool; | 254 ngx_slab_pool_t *shpool; |
253 ngx_rbtree_node_t *sentinel; | 255 ngx_rbtree_node_t *sentinel; |
254 ngx_http_limit_zone_ctx_t *ctx; | 256 ngx_http_limit_zone_ctx_t *ctx; |
255 | 257 |
258 ctx = shm_zone->data; | |
259 | |
260 if (octx) { | |
261 if (ngx_strcmp(ctx->var.data, octx->var.data) != 0) { | |
262 ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0, | |
263 "limit_zone \"%V\" use the \"%V\" variable " | |
264 "while previously it used the \"%V\" variable", | |
265 &shm_zone->name, &ctx->var, &octx->var); | |
266 return NGX_ERROR; | |
267 } | |
268 | |
269 ctx->rbtree = octx->rbtree; | |
270 | |
271 return NGX_OK; | |
272 } | |
273 | |
256 shpool = (ngx_slab_pool_t *) shm_zone->shm.addr; | 274 shpool = (ngx_slab_pool_t *) shm_zone->shm.addr; |
257 ctx = shm_zone->data; | |
258 | 275 |
259 ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t)); | 276 ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t)); |
260 if (ctx->rbtree == NULL) { | 277 if (ctx->rbtree == NULL) { |
261 return NGX_ERROR; | 278 return NGX_ERROR; |
262 } | 279 } |