@@ -28,6 +28,9 @@ static ngx_inline ngx_queue_t *
2828    size_t  len );
2929static  int  ngx_meta_lua_shdict_expire (ngx_meta_lua_shdict_ctx_t  * ctx ,
3030    ngx_uint_t  n );
31+ #if  (NGX_DEBUG )
32+ static  int  ngx_meta_lua_shdict_get_info (lua_State  * L );
33+ #endif 
3134static  int  ngx_meta_lua_shdict_push_helper (lua_State  * L , int  flags );
3235static  int  ngx_meta_lua_shdict_pop_helper (lua_State  * L , int  flags );
3336static  int  ngx_meta_lua_shdict_flush_expired (lua_State  * L );
@@ -210,9 +213,16 @@ ngx_meta_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
210213
211214    ctx  =  shm_zone -> data ;
212215
216+ #if  (NGX_DEBUG )
217+     ctx -> isinit  =  1 ;
218+ #endif 
219+ 
213220    if  (octx ) {
214221        ctx -> sh  =  octx -> sh ;
215222        ctx -> shpool  =  octx -> shpool ;
223+ #if  (NGX_DEBUG )
224+         ctx -> isold  =  1 ;
225+ #endif 
216226
217227        return  NGX_OK ;
218228    }
@@ -340,6 +350,11 @@ ngx_meta_lua_inject_shdict_api(lua_State *L, ngx_cycle_t *cycle, void *tag)
340350        lua_pushcfunction (L , ngx_meta_lua_shdict_get_keys );
341351        lua_setfield (L , -2 , "get_keys" );
342352
353+ #if  (NGX_DEBUG )
354+         lua_pushcfunction (L , ngx_meta_lua_shdict_get_info );
355+         lua_setfield (L , -2 , "get_info" );
356+ #endif 
357+ 
343358        lua_pushvalue (L , -1 ); /* shared mt mt */ 
344359        lua_setfield (L , -2 , "__index" ); /* shared mt */ 
345360
@@ -1282,6 +1297,39 @@ ngx_meta_lua_shdict_llen(lua_State *L)
12821297}
12831298
12841299
1300+ #if  (NGX_DEBUG )
1301+ static  int 
1302+ ngx_meta_lua_shdict_get_info (lua_State  * L )
1303+ {
1304+     ngx_int_t                          n ;
1305+     ngx_shm_zone_t                    * zone ;
1306+     ngx_meta_lua_shdict_ctx_t         * ctx ;
1307+ 
1308+     n  =  lua_gettop (L );
1309+ 
1310+     if  (n  !=  1 ) {
1311+         return  luaL_error (L , "expecting exactly one argument, but seen %d" , n );
1312+     }
1313+ 
1314+     luaL_checktype (L , 1 , LUA_TTABLE );
1315+ 
1316+     zone  =  ngx_meta_lua_shdict_get_zone (L , 1 );
1317+     if  (zone  ==  NULL ) {
1318+         return  luaL_error (L , "bad \"zone\" argument" );
1319+     }
1320+ 
1321+     ctx  =  (ngx_meta_lua_shdict_ctx_t  * ) zone -> data ;
1322+ 
1323+     lua_pushlstring (L , (char  * ) zone -> shm .name .data , zone -> shm .name .len );
1324+     lua_pushnumber (L , zone -> shm .size );
1325+     lua_pushboolean (L , ctx -> isinit );
1326+     lua_pushboolean (L , ctx -> isold );
1327+ 
1328+     return  4 ;
1329+ }
1330+ #endif 
1331+ 
1332+ 
12851333ngx_shm_zone_t  * 
12861334ngx_meta_lua_ffi_shdict_udata_to_zone (void  * zone_udata )
12871335{
0 commit comments