@@ -3814,10 +3814,10 @@ ngx_http_lua_close_fake_connection(ngx_connection_t *c)
3814
3814
}
3815
3815
3816
3816
3817
- lua_State *
3818
- ngx_http_lua_init_vm (lua_State * parent_vm , ngx_cycle_t * cycle ,
3819
- ngx_pool_t * pool , ngx_http_lua_main_conf_t * lmcf , ngx_log_t * log ,
3820
- ngx_pool_cleanup_t * * pcln )
3817
+ ngx_int_t
3818
+ ngx_http_lua_init_vm (lua_State * * new_vm , lua_State * parent_vm ,
3819
+ ngx_cycle_t * cycle , ngx_pool_t * pool , ngx_http_lua_main_conf_t * lmcf ,
3820
+ ngx_log_t * log , ngx_pool_cleanup_t * * pcln )
3821
3821
{
3822
3822
int rc ;
3823
3823
lua_State * L ;
@@ -3828,13 +3828,13 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
3828
3828
3829
3829
cln = ngx_pool_cleanup_add (pool , 0 );
3830
3830
if (cln == NULL ) {
3831
- return NULL ;
3831
+ return NGX_ERROR ;
3832
3832
}
3833
3833
3834
3834
/* create new Lua VM instance */
3835
3835
L = ngx_http_lua_new_state (parent_vm , cycle , lmcf , log );
3836
3836
if (L == NULL ) {
3837
- return NULL ;
3837
+ return NGX_ERROR ;
3838
3838
}
3839
3839
3840
3840
ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , log , 0 , "lua initialize the "
@@ -3845,7 +3845,7 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
3845
3845
3846
3846
state = ngx_alloc (sizeof (ngx_http_lua_vm_state_t ), log );
3847
3847
if (state == NULL ) {
3848
- return NULL ;
3848
+ return NGX_ERROR ;
3849
3849
}
3850
3850
state -> vm = L ;
3851
3851
state -> count = 1 ;
@@ -3878,7 +3878,8 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
3878
3878
3879
3879
for (i = 0 ; i < lmcf -> preload_hooks -> nelts ; i ++ ) {
3880
3880
3881
- ngx_http_lua_probe_register_preload_package (L , hook [i ].package );
3881
+ ngx_http_lua_probe_register_preload_package (L ,
3882
+ hook [i ].package );
3882
3883
3883
3884
lua_pushcfunction (L , hook [i ].loader );
3884
3885
lua_setfield (L , -2 , (char * ) hook [i ].package );
@@ -3887,22 +3888,17 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
3887
3888
lua_pop (L , 2 );
3888
3889
}
3889
3890
3890
- if (lmcf -> load_resty_core ) {
3891
- lua_getglobal (L , "require" );
3892
- lua_pushstring (L , "resty.core" );
3891
+ * new_vm = L ;
3893
3892
3894
- rc = lua_pcall (L , 1 , 1 , 0 );
3895
- if (rc != 0 ) {
3896
- ngx_log_error (NGX_LOG_ERR , log , 0 ,
3897
- "lua_load_resty_core failed to load the resty.core "
3898
- "module from https://github.com/openresty/lua-resty"
3899
- "-core; ensure you are using an OpenResty release "
3900
- "from https://openresty.org/en/download.html "
3901
- "(rc: %i, reason: %s)" , rc , lua_tostring (L , -1 ));
3902
- }
3893
+ lua_getglobal (L , "require" );
3894
+ lua_pushstring (L , "resty.core" );
3895
+
3896
+ rc = lua_pcall (L , 1 , 1 , 0 );
3897
+ if (rc != 0 ) {
3898
+ return NGX_DECLINED ;
3903
3899
}
3904
3900
3905
- return L ;
3901
+ return NGX_OK ;
3906
3902
}
3907
3903
3908
3904
0 commit comments