@@ -84,10 +84,7 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
84
84
ngx_http_lua_shdict_ctx_t * octx = data ;
85
85
86
86
size_t len ;
87
- ngx_int_t rc ;
88
- volatile ngx_cycle_t * saved_cycle ;
89
87
ngx_http_lua_shdict_ctx_t * ctx ;
90
- ngx_http_lua_main_conf_t * lmcf ;
91
88
92
89
dd ("init zone" );
93
90
@@ -97,15 +94,15 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
97
94
ctx -> sh = octx -> sh ;
98
95
ctx -> shpool = octx -> shpool ;
99
96
100
- goto done ;
97
+ return NGX_OK ;
101
98
}
102
99
103
100
ctx -> shpool = (ngx_slab_pool_t * ) shm_zone -> shm .addr ;
104
101
105
102
if (shm_zone -> shm .exists ) {
106
103
ctx -> sh = ctx -> shpool -> data ;
107
104
108
- goto done ;
105
+ return NGX_OK ;
109
106
}
110
107
111
108
ctx -> sh = ngx_slab_alloc (ctx -> shpool , sizeof (ngx_http_lua_shdict_shctx_t ));
@@ -134,32 +131,6 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
134
131
ctx -> shpool -> log_nomem = 0 ;
135
132
#endif
136
133
137
- done :
138
-
139
- dd ("get lmcf" );
140
-
141
- lmcf = ctx -> main_conf ;
142
-
143
- dd ("lmcf->lua: %p" , lmcf -> lua );
144
-
145
- lmcf -> shm_zones_inited ++ ;
146
-
147
- if (lmcf -> shm_zones_inited == lmcf -> shm_zones -> nelts
148
- && lmcf -> init_handler )
149
- {
150
- saved_cycle = ngx_cycle ;
151
- ngx_cycle = ctx -> cycle ;
152
-
153
- rc = lmcf -> init_handler (ctx -> log , lmcf , lmcf -> lua );
154
-
155
- ngx_cycle = saved_cycle ;
156
-
157
- if (rc != NGX_OK ) {
158
- /* an error happened */
159
- return NGX_ERROR ;
160
- }
161
- }
162
-
163
134
return NGX_OK ;
164
135
}
165
136
@@ -355,8 +326,8 @@ ngx_http_lua_inject_shdict_api(ngx_http_lua_main_conf_t *lmcf, lua_State *L)
355
326
ngx_uint_t i ;
356
327
ngx_shm_zone_t * * zone ;
357
328
358
- if (lmcf -> shm_zones != NULL ) {
359
- lua_createtable (L , 0 , lmcf -> shm_zones -> nelts /* nrec */ );
329
+ if (lmcf -> shdict_zones != NULL ) {
330
+ lua_createtable (L , 0 , lmcf -> shdict_zones -> nelts /* nrec */ );
360
331
/* ngx.shared */
361
332
362
333
lua_createtable (L , 0 /* narr */ , 18 /* nrec */ ); /* shared mt */
@@ -415,9 +386,9 @@ ngx_http_lua_inject_shdict_api(ngx_http_lua_main_conf_t *lmcf, lua_State *L)
415
386
lua_pushvalue (L , -1 ); /* shared mt mt */
416
387
lua_setfield (L , -2 , "__index" ); /* shared mt */
417
388
418
- zone = lmcf -> shm_zones -> elts ;
389
+ zone = lmcf -> shdict_zones -> elts ;
419
390
420
- for (i = 0 ; i < lmcf -> shm_zones -> nelts ; i ++ ) {
391
+ for (i = 0 ; i < lmcf -> shdict_zones -> nelts ; i ++ ) {
421
392
ctx = zone [i ]-> data ;
422
393
423
394
lua_pushlstring (L , (char * ) ctx -> name .data , ctx -> name .len );
@@ -2202,6 +2173,7 @@ ngx_http_lua_find_zone(u_char *name_data, size_t name_len)
2202
2173
ngx_str_t * name ;
2203
2174
ngx_uint_t i ;
2204
2175
ngx_shm_zone_t * zone ;
2176
+ ngx_http_lua_shm_zone_ctx_t * ctx ;
2205
2177
volatile ngx_list_part_t * part ;
2206
2178
2207
2179
part = & ngx_cycle -> shared_memory .part ;
@@ -2227,7 +2199,8 @@ ngx_http_lua_find_zone(u_char *name_data, size_t name_len)
2227
2199
if (name -> len == name_len
2228
2200
&& ngx_strncmp (name -> data , name_data , name_len ) == 0 )
2229
2201
{
2230
- return & zone [i ];
2202
+ ctx = (ngx_http_lua_shm_zone_ctx_t * ) zone [i ].data ;
2203
+ return & ctx -> zone ;
2231
2204
}
2232
2205
}
2233
2206
0 commit comments