Skip to content

Commit aef03eb

Browse files
spacewanderthibaultcha
authored andcommitted
feature: added the C API to support the 'ngx.pipe' module provided by lua-resty-core.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com> Signed-off-by: Thibault Charbonnier <thibaultcha@me.com>
1 parent 2c89849 commit aef03eb

File tree

5 files changed

+2628
-0
lines changed

5 files changed

+2628
-0
lines changed

config

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ HTTP_LUA_SRCS=" \
362362
$ngx_addon_dir/src/ngx_http_lua_ssl.c \
363363
$ngx_addon_dir/src/ngx_http_lua_log_ringbuf.c \
364364
$ngx_addon_dir/src/ngx_http_lua_input_filters.c \
365+
$ngx_addon_dir/src/ngx_http_lua_pipe.c \
365366
"
366367

367368
HTTP_LUA_DEPS=" \
@@ -424,6 +425,7 @@ HTTP_LUA_DEPS=" \
424425
$ngx_addon_dir/src/ngx_http_lua_ssl.h \
425426
$ngx_addon_dir/src/ngx_http_lua_log_ringbuf.h \
426427
$ngx_addon_dir/src/ngx_http_lua_input_filters.h \
428+
$ngx_addon_dir/src/ngx_http_lua_pipe.h \
427429
"
428430

429431
CFLAGS="$CFLAGS -DNDK_SET_VAR"
@@ -525,6 +527,36 @@ CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
525527

526528
# ----------------------------------------
527529

530+
ngx_feature="pipe2"
531+
ngx_feature_libs=
532+
ngx_feature_name="NGX_HTTP_LUA_HAVE_PIPE2"
533+
ngx_feature_run=no
534+
ngx_feature_incs="#include <fcntl.h>"
535+
ngx_feature_test="int fd[2]; pipe2(fd, O_CLOEXEC|O_NONBLOCK);"
536+
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
537+
CC_TEST_FLAGS="-Werror -Wall $CC_TEST_FLAGS"
538+
539+
. auto/feature
540+
541+
CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
542+
543+
# ----------------------------------------
544+
545+
ngx_feature="signalfd"
546+
ngx_feature_libs=
547+
ngx_feature_name="NGX_HTTP_LUA_HAVE_SIGNALFD"
548+
ngx_feature_run=no
549+
ngx_feature_incs="#include <sys/signalfd.h>"
550+
ngx_feature_test="sigset_t set; signalfd(-1, &set, SFD_NONBLOCK|SFD_CLOEXEC);"
551+
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
552+
CC_TEST_FLAGS="-Werror -Wall $CC_TEST_FLAGS"
553+
554+
. auto/feature
555+
556+
CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
557+
558+
# ----------------------------------------
559+
528560
if test -n "$ngx_module_link"; then
529561
ngx_module_type=HTTP_AUX_FILTER
530562
ngx_module_name=$ngx_addon_name

src/ngx_http_lua_initworkerby.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "ngx_http_lua_initworkerby.h"
1414
#include "ngx_http_lua_util.h"
15+
#include "ngx_http_lua_pipe.h"
1516

1617

1718
static u_char *ngx_http_lua_log_init_worker_error(ngx_log_t *log,
@@ -65,6 +66,13 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
6566

6667
return NGX_OK;
6768
}
69+
70+
#ifdef HAVE_NGX_LUA_PIPE
71+
if (ngx_http_lua_pipe_add_signal_handler(cycle) != NGX_OK) {
72+
return NGX_ERROR;
73+
}
74+
#endif
75+
6876
#endif /* NGX_WIN32 */
6977

7078
#if (NGX_HTTP_LUA_HAVE_SA_RESTART)

src/ngx_http_lua_module.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "ngx_http_lua_ssl_session_storeby.h"
3030
#include "ngx_http_lua_ssl_session_fetchby.h"
3131
#include "ngx_http_lua_headers.h"
32+
#include "ngx_http_lua_pipe.h"
3233

3334

3435
static void *ngx_http_lua_create_main_conf(ngx_conf_t *cf);
@@ -742,6 +743,11 @@ ngx_http_lua_init(ngx_conf_t *cf)
742743

743744
cln->data = lmcf;
744745
cln->handler = ngx_http_lua_sema_mm_cleanup;
746+
747+
#ifdef HAVE_NGX_LUA_PIPE
748+
ngx_http_lua_pipe_init();
749+
#endif
750+
745751
#endif
746752

747753
#if nginx_version >= 1011011

0 commit comments

Comments
 (0)