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 | |
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>
-rw-r--r-- | auto/njs | 6 | ||||
-rw-r--r-- | docs/changes.xml | 6 | ||||
-rw-r--r-- | pkg/contrib/src/njs/SHA512SUMS | 2 | ||||
-rw-r--r-- | pkg/contrib/src/njs/version | 2 | ||||
-rw-r--r-- | src/nxt_js.c | 18 | ||||
-rw-r--r-- | src/nxt_script.c | 10 |
6 files changed, 19 insertions, 25 deletions
@@ -25,8 +25,8 @@ nxt_feature_incs="$NXT_NJS_CFLAGS $NXT_NJS_AUX_CFLAGS" nxt_feature_libs="$NXT_NJS_LIBS $NXT_NJS_AUX_LIBS" nxt_feature_test="#include <njs.h> - #if NJS_VERSION_NUMBER < 0x000800 - # error NJS < 0.8.0 is not supported. + #if NJS_VERSION_NUMBER < 0x000803 + # error NJS < 0.8.3 is not supported. #endif int main(void) { @@ -44,7 +44,7 @@ nxt_feature_test="#include <njs.h> if [ $nxt_found = no ]; then $echo - $echo $0: error: no NJS library \>= 0.8.0 found. + $echo $0: error: no NJS library \>= 0.8.3 found. $echo exit 1; fi diff --git a/docs/changes.xml b/docs/changes.xml index 6428d65e..84682308 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -34,6 +34,12 @@ NGINX Unit updated to 1.33.0. date="" time="" packager="Nginx Packaging <nginx-packaging@f5.com>"> +<change type="change"> +<para> +if building with NJS, version 0.8.3 or later is now required. +</para> +</change> + </changes> diff --git a/pkg/contrib/src/njs/SHA512SUMS b/pkg/contrib/src/njs/SHA512SUMS index 43766487..47dbee05 100644 --- a/pkg/contrib/src/njs/SHA512SUMS +++ b/pkg/contrib/src/njs/SHA512SUMS @@ -1 +1 @@ -cc3110a0c6866dfc03d19c58745e5b75aa9792999db45bc55a752f7b04db8ae51322bfe0156b873109c8477c6c1a030c851c770697cf6791c6e89fb2fed0a2c5 njs-0.8.2.tar.gz +1cec9a322c40aa2b4ec6eb5bea78d7442880b0cff3a41ad171a3dc3157a6990baec6c8b9eda99ee02a9e51c0b933f13ef17431079a5ff409aaf84b912c7f4df7 njs-0.8.3.tar.gz diff --git a/pkg/contrib/src/njs/version b/pkg/contrib/src/njs/version index 00453419..8b8d5b91 100644 --- a/pkg/contrib/src/njs/version +++ b/pkg/contrib/src/njs/version @@ -1 +1 @@ -NJS_VERSION := 0.8.2 +NJS_VERSION := 0.8.3 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; } diff --git a/src/nxt_script.c b/src/nxt_script.c index 70045a22..05d9561d 100644 --- a/src/nxt_script.c +++ b/src/nxt_script.c @@ -37,14 +37,6 @@ static void nxt_script_buf_completion(nxt_task_t *task, void *obj, void *data); static nxt_lvlhsh_t nxt_script_info; -static njs_vm_ops_t nxt_js_ops = { - NULL, - NULL, - nxt_js_module_loader, - NULL, -}; - - nxt_script_t * nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size, u_char *error) @@ -63,8 +55,6 @@ nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size, opts.file.start = (u_char *) "default"; opts.file.length = 7; - opts.ops = &nxt_js_ops; - vm = njs_vm_create(&opts); if (nxt_slow_path(vm == NULL)) { return NULL; |