Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 9993814

Browse files
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>
1 parent abcfc4c commit 9993814

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

auto/njs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ nxt_feature_incs="$NXT_NJS_CFLAGS $NXT_NJS_AUX_CFLAGS"
2525
nxt_feature_libs="$NXT_NJS_LIBS $NXT_NJS_AUX_LIBS"
2626
nxt_feature_test="#include <njs.h>
2727

28-
#if NJS_VERSION_NUMBER < 0x000800
29-
# error NJS < 0.8.0 is not supported.
28+
#if NJS_VERSION_NUMBER < 0x000803
29+
# error NJS < 0.8.3 is not supported.
3030
#endif
3131

3232
int main(void) {
@@ -44,7 +44,7 @@ nxt_feature_test="#include <njs.h>
4444

4545
if [ $nxt_found = no ]; then
4646
$echo
47-
$echo $0: error: no NJS library \>= 0.8.0 found.
47+
$echo $0: error: no NJS library \>= 0.8.3 found.
4848
$echo
4949
exit 1;
5050
fi

docs/changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ NGINX Unit updated to 1.33.0.
3434
date="" time=""
3535
packager="Nginx Packaging &lt;nginx-packaging@f5.com&gt;">
3636

37+
<change type="change">
38+
<para>
39+
if building with NJS, version 0.8.3 or later is now required.
40+
</para>
41+
</change>
42+
3743
</changes>
3844

3945

pkg/contrib/src/njs/SHA512SUMS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cc3110a0c6866dfc03d19c58745e5b75aa9792999db45bc55a752f7b04db8ae51322bfe0156b873109c8477c6c1a030c851c770697cf6791c6e89fb2fed0a2c5 njs-0.8.2.tar.gz
1+
1cec9a322c40aa2b4ec6eb5bea78d7442880b0cff3a41ad171a3dc3157a6990baec6c8b9eda99ee02a9e51c0b933f13ef17431079a5ff409aaf84b912c7f4df7 njs-0.8.3.tar.gz

pkg/contrib/src/njs/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NJS_VERSION := 0.8.2
1+
NJS_VERSION := 0.8.3

src/nxt_js.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ nxt_js_module_loader(njs_vm_t *vm, njs_external_ptr_t external, njs_str_t *name)
6969
}
7070

7171

72-
static njs_vm_ops_t nxt_js_ops = {
73-
NULL,
74-
NULL,
75-
nxt_js_module_loader,
76-
NULL,
77-
};
78-
79-
8072
njs_int_t nxt_js_proto_id;
8173

8274

@@ -127,6 +119,7 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)
127119
{
128120
u_char *p;
129121
size_t size;
122+
njs_vm_t *vm;
130123
nxt_uint_t i;
131124
njs_vm_opt_t opts;
132125
nxt_js_module_t *module, *mod;
@@ -146,7 +139,6 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)
146139
goto done;
147140
}
148141

149-
opts.ops = &nxt_js_ops;
150142
opts.external = jcf;
151143

152144
size = 0;
@@ -203,7 +195,13 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)
203195

204196
done:
205197

206-
return njs_vm_create(&opts);
198+
vm = njs_vm_create(&opts);
199+
200+
if (nxt_fast_path(vm != NULL)) {
201+
njs_vm_set_module_loader(vm, nxt_js_module_loader, jcf);
202+
}
203+
204+
return vm;
207205
}
208206

209207

src/nxt_script.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ static void nxt_script_buf_completion(nxt_task_t *task, void *obj, void *data);
3737
static nxt_lvlhsh_t nxt_script_info;
3838

3939

40-
static njs_vm_ops_t nxt_js_ops = {
41-
NULL,
42-
NULL,
43-
nxt_js_module_loader,
44-
NULL,
45-
};
46-
47-
4840
nxt_script_t *
4941
nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size,
5042
u_char *error)
@@ -63,8 +55,6 @@ nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size,
6355
opts.file.start = (u_char *) "default";
6456
opts.file.length = 7;
6557

66-
opts.ops = &nxt_js_ops;
67-
6858
vm = njs_vm_create(&opts);
6959
if (nxt_slow_path(vm == NULL)) {
7060
return NULL;

0 commit comments

Comments
 (0)