mirror of
https://github.com/nginx/nginx.git
synced 2024-12-04 22:09:01 +08:00
pass the inherited shm_zone data
This commit is contained in:
parent
1691aaf290
commit
4e77a2bb83
@ -402,6 +402,13 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
|
if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
|
||||||
shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
|
shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
|
||||||
|
|
||||||
|
if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)
|
||||||
|
!= NGX_OK)
|
||||||
|
{
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +453,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
ngx_slab_init(shpool);
|
ngx_slab_init(shpool);
|
||||||
|
|
||||||
if (shm_zone[i].init(&shm_zone[i]) != NGX_OK) {
|
if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
typedef struct ngx_shm_zone_s ngx_shm_zone_t;
|
typedef struct ngx_shm_zone_s ngx_shm_zone_t;
|
||||||
|
|
||||||
typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone);
|
typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data);
|
||||||
|
|
||||||
struct ngx_shm_zone_s {
|
struct ngx_shm_zone_s {
|
||||||
void *data;
|
void *data;
|
||||||
|
@ -23,7 +23,8 @@ static void ngx_ssl_shutdown_handler(ngx_event_t *ev);
|
|||||||
static void ngx_ssl_connection_error(ngx_connection_t *c, int sslerr,
|
static void ngx_ssl_connection_error(ngx_connection_t *c, int sslerr,
|
||||||
ngx_err_t err, char *text);
|
ngx_err_t err, char *text);
|
||||||
|
|
||||||
static ngx_int_t ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone);
|
static ngx_int_t ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone,
|
||||||
|
void *data);
|
||||||
static int ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn,
|
static int ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn,
|
||||||
ngx_ssl_session_t *sess);
|
ngx_ssl_session_t *sess);
|
||||||
static ngx_ssl_session_t *ngx_ssl_get_cached_session(ngx_ssl_conn_t *ssl_conn,
|
static ngx_ssl_session_t *ngx_ssl_get_cached_session(ngx_ssl_conn_t *ssl_conn,
|
||||||
@ -1184,12 +1185,17 @@ ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone)
|
ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone, void *data)
|
||||||
{
|
{
|
||||||
ngx_slab_pool_t *shpool;
|
ngx_slab_pool_t *shpool;
|
||||||
ngx_rbtree_node_t *sentinel;
|
ngx_rbtree_node_t *sentinel;
|
||||||
ngx_ssl_session_cache_t *cache;
|
ngx_ssl_session_cache_t *cache;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
shm_zone->data = data;
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
|
shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
|
||||||
|
|
||||||
cache = ngx_slab_alloc(shpool, sizeof(ngx_ssl_session_cache_t));
|
cache = ngx_slab_alloc(shpool, sizeof(ngx_ssl_session_cache_t));
|
||||||
|
@ -247,15 +247,32 @@ ngx_http_limit_zone_cleanup(void *data)
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone)
|
ngx_http_limit_zone_init_zone(ngx_shm_zone_t *shm_zone, void *data)
|
||||||
{
|
{
|
||||||
|
ngx_http_limit_zone_ctx_t *octx = data;
|
||||||
|
|
||||||
ngx_slab_pool_t *shpool;
|
ngx_slab_pool_t *shpool;
|
||||||
ngx_rbtree_node_t *sentinel;
|
ngx_rbtree_node_t *sentinel;
|
||||||
ngx_http_limit_zone_ctx_t *ctx;
|
ngx_http_limit_zone_ctx_t *ctx;
|
||||||
|
|
||||||
shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
|
|
||||||
ctx = shm_zone->data;
|
ctx = shm_zone->data;
|
||||||
|
|
||||||
|
if (octx) {
|
||||||
|
if (ngx_strcmp(ctx->var.data, octx->var.data) != 0) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0,
|
||||||
|
"limit_zone \"%V\" use the \"%V\" variable "
|
||||||
|
"while previously it used the \"%V\" variable",
|
||||||
|
&shm_zone->name, &ctx->var, &octx->var);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->rbtree = octx->rbtree;
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
|
||||||
|
|
||||||
ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t));
|
ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t));
|
||||||
if (ctx->rbtree == NULL) {
|
if (ctx->rbtree == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user