diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2024-02-16 18:22:35 +0000 |
---|---|---|
committer | andrey-zelenkov <xim.andrew@gmail.com> | 2024-03-12 16:56:11 +0000 |
commit | 9993814d14fa693dc8641c31bca70223895d2055 (patch) | |
tree | 1845a910be997cdd2678bcd0bbfe8113ba5e5305 /src/nxt_js.c | |
parent | abcfc4cd6871c57af05fa2ee1c3fe80dfc556cdc (diff) | |
download | unit-9993814d14fa693dc8641c31bca70223895d2055.tar.gz unit-9993814d14fa693dc8641c31bca70223895d2055.tar.bz2 |
NJS: loader should be registered using njs_vm_set_module_loader()
This change makes NJS module incompatible with NJS older than 0.8.3.
Therefore, the configuration version check has been adjusted accordingly.
This change was introduced in NJS 0.8.3 here:
<https://hg.nginx.com/njs/rev/ad1a7ad3c715>
Diffstat (limited to 'src/nxt_js.c')
-rw-r--r-- | src/nxt_js.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/nxt_js.c b/src/nxt_js.c index 6885afb7..1f9a3ceb 100644 --- a/src/nxt_js.c +++ b/src/nxt_js.c @@ -69,14 +69,6 @@ nxt_js_module_loader(njs_vm_t *vm, njs_external_ptr_t external, njs_str_t *name) } -static njs_vm_ops_t nxt_js_ops = { - NULL, - NULL, - nxt_js_module_loader, - NULL, -}; - - njs_int_t nxt_js_proto_id; @@ -127,6 +119,7 @@ nxt_js_vm_create(nxt_js_conf_t *jcf) { u_char *p; size_t size; + njs_vm_t *vm; nxt_uint_t i; njs_vm_opt_t opts; nxt_js_module_t *module, *mod; @@ -146,7 +139,6 @@ nxt_js_vm_create(nxt_js_conf_t *jcf) goto done; } - opts.ops = &nxt_js_ops; opts.external = jcf; size = 0; @@ -203,7 +195,13 @@ nxt_js_vm_create(nxt_js_conf_t *jcf) done: - return njs_vm_create(&opts); + vm = njs_vm_create(&opts); + + if (nxt_fast_path(vm != NULL)) { + njs_vm_set_module_loader(vm, nxt_js_module_loader, jcf); + } + + return vm; } |