Klaus Demo nginx / 4e77a2b
pass the inherited shm_zone data Igor Sysoev 15 years ago
4 changed file(s) with 37 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
401401
402402 if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
403403 shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
404
405 if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)
406 != NGX_OK)
407 {
408 goto failed;
409 }
410
404411 goto found;
405412 }
406413
445452
446453 ngx_slab_init(shpool);
447454
448 if (shm_zone[i].init(&shm_zone[i]) != NGX_OK) {
455 if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
449456 goto failed;
450457 }
451458
2222
2323 typedef struct ngx_shm_zone_s ngx_shm_zone_t;
2424
25 typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone);
25 typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data);
2626
2727 struct ngx_shm_zone_s {
2828 void *data;
2222 static void ngx_ssl_connection_error(ngx_connection_t *c, int sslerr,
2323 ngx_err_t err, char *text);
2424
25 static ngx_int_t ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone);
25 static ngx_int_t ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone,
26 void *data);
2627 static int ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn,
2728 ngx_ssl_session_t *sess);
2829 static ngx_ssl_session_t *ngx_ssl_get_cached_session(ngx_ssl_conn_t *ssl_conn,
11831184
11841185
11851186 static ngx_int_t
1186 ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone)
1187 ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone, void *data)
11871188 {
11881189 ngx_slab_pool_t *shpool;
11891190 ngx_rbtree_node_t *sentinel;
11901191 ngx_ssl_session_cache_t *cache;
1192
1193 if (data) {
1194 shm_zone->data = data;
1195 return NGX_OK;
1196 }
11911197
11921198 shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
11931199
246246
247247
248248 static ngx_int_t
249 ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone)
250 {
249 ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone, void *data)
250 {
251 ngx_http_limit_zone_ctx_t *octx = data;
252
251253 ngx_slab_pool_t *shpool;
252254 ngx_rbtree_node_t *sentinel;
253255 ngx_http_limit_zone_ctx_t *ctx;
254256
257 ctx = shm_zone->data;
258
259 if (octx) {
260 if (ngx_strcmp(ctx->var.data, octx->var.data) != 0) {
261 ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0,
262 "limit_zone \"%V\" use the \"%V\" variable "
263 "while previously it used the \"%V\" variable",
264 &shm_zone->name, &ctx->var, &octx->var);
265 return NGX_ERROR;
266 }
267
268 ctx->rbtree = octx->rbtree;
269
270 return NGX_OK;
271 }
272
255273 shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
256 ctx = shm_zone->data;
257274
258275 ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t));
259276 if (ctx->rbtree == NULL) {