@@ -28,6 +28,9 @@ static ngx_inline ngx_queue_t *
28
28
size_t len );
29
29
static int ngx_meta_lua_shdict_expire (ngx_meta_lua_shdict_ctx_t * ctx ,
30
30
ngx_uint_t n );
31
+ #if (NGX_DEBUG )
32
+ static int ngx_meta_lua_shdict_get_info (lua_State * L );
33
+ #endif
31
34
static int ngx_meta_lua_shdict_push_helper (lua_State * L , int flags );
32
35
static int ngx_meta_lua_shdict_pop_helper (lua_State * L , int flags );
33
36
static 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)
210
213
211
214
ctx = shm_zone -> data ;
212
215
216
+ #if (NGX_DEBUG )
217
+ ctx -> isinit = 1 ;
218
+ #endif
219
+
213
220
if (octx ) {
214
221
ctx -> sh = octx -> sh ;
215
222
ctx -> shpool = octx -> shpool ;
223
+ #if (NGX_DEBUG )
224
+ ctx -> isold = 1 ;
225
+ #endif
216
226
217
227
return NGX_OK ;
218
228
}
@@ -340,6 +350,11 @@ ngx_meta_lua_inject_shdict_api(lua_State *L, ngx_cycle_t *cycle, void *tag)
340
350
lua_pushcfunction (L , ngx_meta_lua_shdict_get_keys );
341
351
lua_setfield (L , -2 , "get_keys" );
342
352
353
+ #if (NGX_DEBUG )
354
+ lua_pushcfunction (L , ngx_meta_lua_shdict_get_info );
355
+ lua_setfield (L , -2 , "get_info" );
356
+ #endif
357
+
343
358
lua_pushvalue (L , -1 ); /* shared mt mt */
344
359
lua_setfield (L , -2 , "__index" ); /* shared mt */
345
360
@@ -1282,6 +1297,39 @@ ngx_meta_lua_shdict_llen(lua_State *L)
1282
1297
}
1283
1298
1284
1299
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
+
1285
1333
ngx_shm_zone_t *
1286
1334
ngx_meta_lua_ffi_shdict_udata_to_zone (void * zone_udata )
1287
1335
{
0 commit comments