aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_http_js_module.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2017-01-27 16:45:34 +0300
committerRoman Arutyunyan <arut@nginx.com>2017-01-27 16:45:34 +0300
commit9c3a4f0bac65da39fe6ec25a95875b059a51585c (patch)
tree02fa07d6108618d7f3a5e55f62255c1361a2f599 /nginx/ngx_http_js_module.c
parenta30cb8b65b8470b4fcd06abfb030f73ecc4e36c6 (diff)
downloadnjs-9c3a4f0bac65da39fe6ec25a95875b059a51585c.tar.gz
njs-9c3a4f0bac65da39fe6ec25a95875b059a51585c.zip
Initialize global variables in njs virtual machines.
Previously, global variables in njs code remained uninitialized even if an initializer existed in njs code. To fix this, njs_vm_run() function is called right after a virtual machine is cloned. This call initializes global variables.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r--nginx/ngx_http_js_module.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index 104ca71f..b2e84481 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -573,6 +573,10 @@ ngx_http_js_init_vm(ngx_http_request_t *r)
return NGX_ERROR;
}
+ if (njs_vm_run(ctx->vm) != NJS_OK) {
+ return NGX_ERROR;
+ }
+
ctx->args = &jlcf->args[0];
return NGX_OK;