Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d15338e

Browse files
committed
feature: this module can now be compiled as a dynamic module with NGINX 1.9.11+ via the --with-dynamic-module=PATH option of ./configure. also fixed issues with other modules are compiled as dynamic modules.
1 parent 645c131 commit d15338e

File tree

3 files changed

+64
-11
lines changed

3 files changed

+64
-11
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Table of Contents
1919
* [array_map](#array_map)
2020
* [array_map_op](#array_map_op)
2121
* [Installation](#installation)
22+
* [Building as a dynamic module](#building-as-a-dynamic-module)
2223
* [Compatibility](#compatibility)
2324
* [Source Repository](#source-repository)
2425
* [Getting involved](#getting-involved)
@@ -284,6 +285,20 @@ Also, this module is included and enabled by default in the [OpenResty bundle](h
284285

285286
[Back to TOC](#table-of-contents)
286287

288+
Building as a dynamic module
289+
----------------------------
290+
291+
Starting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the `--add-dynamic-module=PATH` option instead of `--add-module=PATH` on the
292+
`./configure` command line above. And then you can explicitly load the module in your `nginx.conf` via the [load_module](http://nginx.org/en/docs/ngx_core_module.html#load_module)
293+
directive, for example,
294+
295+
```nginx
296+
load_module /path/to/modules/ndk_http_module.so; # assuming NDK is built as a dynamic module too
297+
load_module /path/to/modules/ngx_http_array_var_module.so;
298+
```
299+
300+
[Back to TOC](#table-of-contents)
301+
287302
Compatibility
288303
==============
289304

config

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
1-
if echo $HTTP_MODULES | grep " ndk_http_module" > /dev/null; then
2-
echo "found ngx_devel_kit for ngx_array_var; looks good."
1+
if test -n "$ngx_module_link"; then
2+
if test -n "$NDK_SRCS"; then
3+
echo "found ngx_devel_kit for ngx_array_var; looks good."
4+
else
5+
echo "error: ngx_devel_kit is required to build ngx_array_var; please put it before ngx_array_var." 1>&2
6+
exit 1
7+
fi
38
else
4-
echo "error: ngx_devel_kit is required to build ngx_array_var; please put it before ngx_array_var." 1>&2
5-
exit 1
9+
if echo $HTTP_MODULES | grep " ndk_http_module" > /dev/null; then
10+
echo "found ngx_devel_kit for ngx_array_var; looks good."
11+
else
12+
echo "error: ngx_devel_kit is required to build ngx_array_var; please put it before ngx_array_var." 1>&2
13+
exit 1
14+
fi
615
fi
716

817
ngx_addon_name=ngx_http_array_var_module
9-
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_array_var_module"
10-
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_array_var_module.c $ngx_addon_dir/src/ngx_http_array_var_util.c"
11-
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ddebug.h $ngx_addon_dir/src/ngx_http_array_var_util.h"
12-
CFLAGS="$CFLAGS -DNDK_SET_VAR"
1318

19+
HTTP_ARRAY_VAR_SRCS=" \
20+
$ngx_addon_dir/src/ngx_http_array_var_module.c \
21+
$ngx_addon_dir/src/ngx_http_array_var_util.c \
22+
"
23+
24+
HTTP_ARRAY_VAR_DEPS=" \
25+
$ngx_addon_dir/src/ddebug.h \
26+
$ngx_addon_dir/src/ngx_http_array_var_util.h \
27+
"
28+
29+
if test -n "$ngx_module_link"; then
30+
ngx_module_type=HTTP
31+
ngx_module_name=$ngx_addon_name
32+
ngx_module_incs=
33+
ngx_module_deps="$HTTP_ARRAY_VAR_DEPS"
34+
ngx_module_srcs="$HTTP_ARRAY_VAR_SRCS"
35+
ngx_module_libs=
36+
37+
. auto/module
38+
else
39+
HTTP_MODULES="$HTTP_MODULES $ngx_addon_name"
40+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $HTTP_ARRAY_VAR_SRCS"
41+
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $HTTP_ARRAY_VAR_DEPS"
42+
fi
43+
44+
CFLAGS="$CFLAGS -DNDK_SET_VAR"

src/ngx_http_array_var_util.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,23 @@ ngx_http_array_var_get_func_from_cmd(u_char *name, size_t name_len)
4848
{
4949
ndk_set_var_t *filter;
5050
ngx_uint_t i;
51+
ngx_module_t **modules;
5152
ngx_module_t *module;
5253
ngx_command_t *cmd;
5354

54-
for (i = 0; ngx_modules[i]; i++) {
55-
module = ngx_modules[i];
55+
#if defined(nginx_version) && nginx_version >= 1009011
56+
modules = ngx_cycle->modules;
57+
#else
58+
modules = ngx_modules;
59+
#endif
60+
61+
for (i = 0; modules[i]; i++) {
62+
module = modules[i];
5663
if (module->type != NGX_HTTP_MODULE) {
5764
continue;
5865
}
5966

60-
cmd = ngx_modules[i]->commands;
67+
cmd = modules[i]->commands;
6168
if (cmd == NULL) {
6269
continue;
6370
}

0 commit comments

Comments
 (0)