@@ -81,7 +81,7 @@ ngx_uint_t ngx_http_lua_content_length_hash = 0;
8181static ngx_int_t ngx_http_lua_send_http10_headers (ngx_http_request_t * r ,
8282 ngx_http_lua_ctx_t * ctx );
8383static void ngx_http_lua_init_registry (lua_State * L , ngx_log_t * log );
84- static void ngx_http_lua_init_globals (lua_State * L ,
84+ static void ngx_http_lua_init_globals (lua_State * L , ngx_cycle_t * cycle ,
8585 ngx_http_lua_main_conf_t * lmcf , ngx_log_t * log );
8686static void ngx_http_lua_set_path (ngx_cycle_t * cycle , lua_State * L , int tab_idx ,
8787 const char * fieldname , const char * path , const char * default_path ,
@@ -294,7 +294,7 @@ ngx_http_lua_new_state(lua_State *parent_vm, ngx_cycle_t *cycle,
294294 lua_pop (L , 1 ); /* remove the "package" table */
295295
296296 ngx_http_lua_init_registry (L , log );
297- ngx_http_lua_init_globals (L , lmcf , log );
297+ ngx_http_lua_init_globals (L , cycle , lmcf , log );
298298
299299 return L ;
300300}
@@ -683,12 +683,15 @@ ngx_http_lua_init_registry(lua_State *L, ngx_log_t *log)
683683
684684
685685static void
686- ngx_http_lua_init_globals (lua_State * L , ngx_http_lua_main_conf_t * lmcf ,
687- ngx_log_t * log )
686+ ngx_http_lua_init_globals (lua_State * L , ngx_cycle_t * cycle ,
687+ ngx_http_lua_main_conf_t * lmcf , ngx_log_t * log )
688688{
689689 ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , log , 0 ,
690690 "lua initializing lua globals" );
691691
692+ lua_pushlightuserdata (L , cycle );
693+ lua_setglobal (L , "__ngx_cycle" );
694+
692695#if defined(NDK ) && NDK
693696 ngx_http_lua_inject_ndk_api (L );
694697#endif /* defined(NDK) && NDK */
0 commit comments