@@ -3814,10 +3814,10 @@ ngx_http_lua_close_fake_connection(ngx_connection_t *c)
38143814}
38153815
38163816
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 )
38213821{
38223822 int rc ;
38233823 lua_State * L ;
@@ -3828,13 +3828,13 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
38283828
38293829 cln = ngx_pool_cleanup_add (pool , 0 );
38303830 if (cln == NULL ) {
3831- return NULL ;
3831+ return NGX_ERROR ;
38323832 }
38333833
38343834 /* create new Lua VM instance */
38353835 L = ngx_http_lua_new_state (parent_vm , cycle , lmcf , log );
38363836 if (L == NULL ) {
3837- return NULL ;
3837+ return NGX_ERROR ;
38383838 }
38393839
38403840 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,
38453845
38463846 state = ngx_alloc (sizeof (ngx_http_lua_vm_state_t ), log );
38473847 if (state == NULL ) {
3848- return NULL ;
3848+ return NGX_ERROR ;
38493849 }
38503850 state -> vm = L ;
38513851 state -> count = 1 ;
@@ -3878,7 +3878,8 @@ ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
38783878
38793879 for (i = 0 ; i < lmcf -> preload_hooks -> nelts ; i ++ ) {
38803880
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 );
38823883
38833884 lua_pushcfunction (L , hook [i ].loader );
38843885 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,
38873888 lua_pop (L , 2 );
38883889 }
38893890
3890- if (lmcf -> load_resty_core ) {
3891- lua_getglobal (L , "require" );
3892- lua_pushstring (L , "resty.core" );
3891+ * new_vm = L ;
38933892
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 ;
39033899 }
39043900
3905- return L ;
3901+ return NGX_OK ;
39063902}
39073903
39083904
0 commit comments