Permalink
Browse files

bugfix: init_by_lua* might be skipped altogether when HUP config relo…

…ad was used.
  • Loading branch information...
1 parent 5445e0e commit ce4314d46fee28c68061c252e31c0d1fd9a5ad7d @agentzh agentzh committed Jul 3, 2012
Showing with 33 additions and 4 deletions.
  1. +1 −1 src/ngx_http_lua_directive.c
  2. +3 −3 src/ngx_http_lua_shdict.c
  3. +29 −0 t/086-init-by.t
@@ -72,7 +72,7 @@ ngx_http_lua_shared_dict(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ctx->name = name;
ctx->main_conf = lmcf;
- ctx->log = cf->log;
+ ctx->log = &cf->cycle->new_log;
zone = ngx_shared_memory_add(cf, &name, (size_t) size,
&ngx_http_lua_module);
@@ -44,17 +44,16 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
if (octx) {
ctx->sh = octx->sh;
ctx->shpool = octx->shpool;
- ctx->log = octx->log;
- return NGX_OK;
+ goto done;
}
ctx->shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
if (shm_zone->shm.exists) {
ctx->sh = ctx->shpool->data;
- return NGX_OK;
+ goto done;
}
ctx->sh = ngx_slab_alloc(ctx->shpool, sizeof(ngx_http_lua_shdict_shctx_t));
@@ -79,6 +78,7 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
ngx_sprintf(ctx->shpool->log_ctx, " in lua_shared_dict zone \"%V\"%Z",
&shm_zone->shm.name);
+done:
dd("get lmcf");
lmcf = ctx->main_conf;
View
@@ -13,6 +13,8 @@ plan tests => repeat_each() * (blocks() * 3);
#no_diff();
#no_long_string();
+no_shuffle();
+
run_tests();
__DATA__
@@ -168,3 +170,30 @@ ok
--- error_log
log from init_by_lua
+
+
+=== TEST 8: require (with shm defined)
+--- http_config
+ lua_package_path "$prefix/html/?.lua;;";
+ lua_shared_dict dogs 1m;
+ init_by_lua 'require "blah"';
+--- config
+ location /lua {
+ content_by_lua '
+ blah.go()
+ ';
+ }
+--- user_files
+>>> blah.lua
+module(..., package.seeall)
+
+function go()
+ ngx.say("hello, blah")
+end
+--- request
+GET /lua
+--- response_body
+hello, blah
+--- no_error_log
+[error]
+

0 comments on commit ce4314d

Please sign in to comment.