[nginx] Core: removed extra ngx_alloc() and ngx_calloc() prototypes.
details: http://hg.nginx.org/nginx/rev/ef935cd7ed8d branches: changeset: 6979:ef935cd7ed8d user: Sergey Kandaurov date: Tue Apr 18 13:01:19 2017 +0300 description: Core: removed extra ngx_alloc() and ngx_calloc() prototypes. diffstat: src/core/ngx_palloc.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diffs (13 lines): diff -r 9fb994513776 -r ef935cd7ed8d src/core/ngx_palloc.h --- a/src/core/ngx_palloc.h Mon Apr 17 14:42:12 2017 +0300 +++ b/src/core/ngx_palloc.h Tue Apr 18 13:01:19 2017 +0300 @@ -72,9 +72,6 @@ typedef struct { } ngx_pool_cleanup_file_t; -void *ngx_alloc(size_t size, ngx_log_t *log); -void *ngx_calloc(size_t size, ngx_log_t *log); - ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log); void ngx_destroy_pool(ngx_pool_t *pool); void ngx_reset_pool(ngx_pool_t *pool); ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] Set UDP datagram source address (ticket #1239).
details: http://hg.nginx.org/nginx/rev/dbb0c854e308 branches: changeset: 6980:dbb0c854e308 user: Roman Arutyunyan date: Tue Apr 11 16:41:53 2017 +0300 description: Set UDP datagram source address (ticket #1239). Previously, the source IP address of a response UDP datagram could differ from the original datagram destination address. This could happen if the server UDP socket is bound to a wildcard address and the network interface chosen to output the response packet has a different default address than the destination address of the original packet. For example, if two addresses from the same network are configured on an interface. Now source address is set explicitly if a response is sent for a server UDP socket bound to a wildcard address. diffstat: auto/unix | 13 + src/os/unix/ngx_udp_sendmsg_chain.c | 90 + 2 files changed, 103 insertions(+), 0 deletions(-) diffs (130 lines): diff -r ef935cd7ed8d -r dbb0c854e308 auto/unix --- a/auto/unix Tue Apr 18 13:01:19 2017 +0300 +++ b/auto/unix Tue Apr 11 16:41:53 2017 +0300 @@ -394,6 +394,19 @@ ngx_feature_test="setsockopt(0, IPPROTO_ . auto/feature +# BSD way to set IPv4 datagram source address + +ngx_feature="IP_SENDSRCADDR" +ngx_feature_name="NGX_HAVE_IP_SENDSRCADDR" +ngx_feature_run=no +ngx_feature_incs="#include + #include " +ngx_feature_path= +ngx_feature_libs= +ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_SENDSRCADDR, NULL, 0)" +. auto/feature + + # Linux way to get IPv4 datagram destination address ngx_feature="IP_PKTINFO" diff -r ef935cd7ed8d -r dbb0c854e308 src/os/unix/ngx_udp_sendmsg_chain.c --- a/src/os/unix/ngx_udp_sendmsg_chain.c Tue Apr 18 13:01:19 2017 +0300 +++ b/src/os/unix/ngx_udp_sendmsg_chain.c Tue Apr 11 16:41:53 2017 +0300 @@ -203,6 +203,20 @@ ngx_sendmsg(ngx_connection_t *c, ngx_iov ngx_err_t err; struct msghdr msg; +#if (NGX_HAVE_MSGHDR_MSG_CONTROL) + +#if (NGX_HAVE_IP_SENDSRCADDR) +u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))]; +#elif (NGX_HAVE_IP_PKTINFO) +u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))]; +#endif + +#if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO) +u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; +#endif + +#endif + ngx_memzero(&msg, sizeof(struct msghdr)); if (c->socklen) { @@ -213,6 +227,82 @@ ngx_sendmsg(ngx_connection_t *c, ngx_iov msg.msg_iov = vec->iovs; msg.msg_iovlen = vec->count; +#if (NGX_HAVE_MSGHDR_MSG_CONTROL) + +if (c->listening && c->listening->wildcard && c->local_sockaddr) { + +#if (NGX_HAVE_IP_SENDSRCADDR) + +if (c->local_sockaddr->sa_family == AF_INET) { +struct cmsghdr *cmsg; +struct in_addr *addr; +struct sockaddr_in *sin; + +msg.msg_control = &msg_control; +msg.msg_controllen = sizeof(msg_control); + +cmsg = CMSG_FIRSTHDR(&msg); +cmsg->cmsg_level = IPPROTO_IP; +cmsg->cmsg_type = IP_SENDSRCADDR; +cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); + +sin = (struct sockaddr_in *) c->local_sockaddr; + +addr = (struct in_addr *) CMSG_DATA(cmsg); +*addr = sin->sin_addr; +} + +#elif (NGX_HAVE_IP_PKTINFO) + +if (c->local_sockaddr->sa_family == AF_INET) { +struct cmsghdr *cmsg; +struct in_pktinfo *pkt; +struct sockaddr_in *sin; + +msg.msg_control = &msg_control; +msg.msg_controllen = sizeof(msg_control); + +cmsg = CMSG_FIRSTHDR(&msg); +cmsg->cmsg_level = IPPROTO_IP; +cmsg->cmsg_type = IP_PKTINFO; +cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); + +sin = (struct sockaddr_in *) c->local_sockaddr; + +pkt = (struct in_pktinfo *) CMSG_DATA(cmsg); +ngx_memzero(pkt, sizeof(struct in_pktinfo)); +pkt->ipi_spec_dst = sin->sin_addr; +} + +#endif + +#if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO) + +if (c->local_sockaddr->sa_family == AF_INET6) { +struct cmsghdr *cmsg; +struct in6_pktinfo *pkt6; +struct sockaddr_in6 *sin6; + +msg.msg_control = &msg_control6; +msg.msg_controllen = sizeof(msg_control6); + +cmsg = CMSG_FIRSTHDR(&msg); +cmsg->cmsg_level = IPPROTO_IPV6; +cmsg->cmsg_type = IPV6_PKTINFO; +cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); + +sin6 = (struct sockaddr_in6 *) c->local_sockaddr; + +pkt6 = (struct in6_pktinfo *) CMSG_DATA(cmsg); +ngx_memzero(pkt6, sizeof(struct in6_pktinfo)); +pkt6->ipi6_addr = sin6->sin6_addr; +} + +#endif +} + +#endif + eintr: n = sendmsg(c->fd, &msg, 0);
[nginx] SSL: added support for TLSv1.3 in ssl_protocols directive.
details: http://hg.nginx.org/nginx/rev/08dc60979133 branches: changeset: 6981:08dc60979133 user: Sergey Kandaurov date: Tue Apr 18 15:12:38 2017 +0300 description: SSL: added support for TLSv1.3 in ssl_protocols directive. Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1. diffstat: src/event/ngx_event_openssl.c| 6 ++ src/event/ngx_event_openssl.h| 1 + src/http/modules/ngx_http_proxy_module.c | 1 + src/http/modules/ngx_http_ssl_module.c | 1 + src/http/modules/ngx_http_uwsgi_module.c | 1 + src/mail/ngx_mail_ssl_module.c | 1 + src/stream/ngx_stream_proxy_module.c | 1 + src/stream/ngx_stream_ssl_module.c | 1 + 8 files changed, 13 insertions(+), 0 deletions(-) diffs (93 lines): diff -r dbb0c854e308 -r 08dc60979133 src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c Tue Apr 11 16:41:53 2017 +0300 +++ b/src/event/ngx_event_openssl.c Tue Apr 18 15:12:38 2017 +0300 @@ -323,6 +323,12 @@ ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_ SSL_CTX_set_options(ssl->ctx, SSL_OP_NO_TLSv1_2); } #endif +#ifdef SSL_OP_NO_TLSv1_3 +SSL_CTX_clear_options(ssl->ctx, SSL_OP_NO_TLSv1_3); +if (!(protocols & NGX_SSL_TLSv1_3)) { +SSL_CTX_set_options(ssl->ctx, SSL_OP_NO_TLSv1_3); +} +#endif #ifdef SSL_OP_NO_COMPRESSION SSL_CTX_set_options(ssl->ctx, SSL_OP_NO_COMPRESSION); diff -r dbb0c854e308 -r 08dc60979133 src/event/ngx_event_openssl.h --- a/src/event/ngx_event_openssl.h Tue Apr 11 16:41:53 2017 +0300 +++ b/src/event/ngx_event_openssl.h Tue Apr 18 15:12:38 2017 +0300 @@ -131,6 +131,7 @@ typedef struct { #define NGX_SSL_TLSv10x0008 #define NGX_SSL_TLSv1_1 0x0010 #define NGX_SSL_TLSv1_2 0x0020 +#define NGX_SSL_TLSv1_3 0x0040 #define NGX_SSL_BUFFER 1 diff -r dbb0c854e308 -r 08dc60979133 src/http/modules/ngx_http_proxy_module.c --- a/src/http/modules/ngx_http_proxy_module.c Tue Apr 11 16:41:53 2017 +0300 +++ b/src/http/modules/ngx_http_proxy_module.c Tue Apr 18 15:12:38 2017 +0300 @@ -235,6 +235,7 @@ static ngx_conf_bitmask_t ngx_http_prox { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; diff -r dbb0c854e308 -r 08dc60979133 src/http/modules/ngx_http_ssl_module.c --- a/src/http/modules/ngx_http_ssl_module.cTue Apr 11 16:41:53 2017 +0300 +++ b/src/http/modules/ngx_http_ssl_module.cTue Apr 18 15:12:38 2017 +0300 @@ -57,6 +57,7 @@ static ngx_conf_bitmask_t ngx_http_ssl_ { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; diff -r dbb0c854e308 -r 08dc60979133 src/http/modules/ngx_http_uwsgi_module.c --- a/src/http/modules/ngx_http_uwsgi_module.c Tue Apr 11 16:41:53 2017 +0300 +++ b/src/http/modules/ngx_http_uwsgi_module.c Tue Apr 18 15:12:38 2017 +0300 @@ -129,6 +129,7 @@ static ngx_conf_bitmask_t ngx_http_uwsg { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; diff -r dbb0c854e308 -r 08dc60979133 src/mail/ngx_mail_ssl_module.c --- a/src/mail/ngx_mail_ssl_module.cTue Apr 11 16:41:53 2017 +0300 +++ b/src/mail/ngx_mail_ssl_module.cTue Apr 18 15:12:38 2017 +0300 @@ -42,6 +42,7 @@ static ngx_conf_bitmask_t ngx_mail_ssl_ { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; diff -r dbb0c854e308 -r 08dc60979133 src/stream/ngx_stream_proxy_module.c --- a/src/stream/ngx_stream_proxy_module.c Tue Apr 11 16:41:53 2017 +0300 +++ b/src/stream/ngx_stream_proxy_module.c Tue Apr 18 15:12:38 2017 +0300 @@ -103,6 +103,7 @@ static ngx_conf_bitmask_t ngx_stream_pr { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; diff -r dbb0c854e308 -r 08dc60979133 src/stream/ngx_stream_ssl_module.c --- a/src/stream/ngx_stream_ssl_module.cTue Apr 11 16:41:53 2017 +0300 +++ b/src/stream/ngx_stream_ssl_module.cTue Apr 18 15:12:38 2017 +0300 @@ -45,6 +45,7 @@ static ngx_conf_bitmask_t ngx_stream_ss { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, +{ ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, { ngx_null_string, 0 } }; ___ nginx-devel mailing li
[nginx] SSL: disabled renegotiation detection in client mode.
details: http://hg.nginx.org/nginx/rev/ac9b1df5b246 branches: changeset: 6982:ac9b1df5b246 user: Sergey Kandaurov date: Tue Apr 18 16:08:44 2017 +0300 description: SSL: disabled renegotiation detection in client mode. CVE-2009-3555 is no longer relevant and mitigated by the renegotiation info extension (secure renegotiation). On the other hand, unexpected renegotiation still introduces potential security risks, and hence we do not allow renegotiation on the server side, as we never request renegotiation. On the client side the situation is different though. There are backends which explicitly request renegotiation, and disabled renegotiation introduces interoperability problems. This change allows renegotiation on the client side, and fixes interoperability problems as observed with such backends (ticket #872). Additionally, with TLSv1.3 the SSL_CB_HANDSHAKE_START flag is currently set by OpenSSL when receiving a NewSessionTicket message, and was detected by nginx as a renegotiation attempt. This looks like a bug in OpenSSL, though this change also allows better interoperability till the problem is fixed. diffstat: src/event/ngx_event_openssl.c | 4 +++- src/event/ngx_event_openssl.h | 5 + 2 files changed, 8 insertions(+), 1 deletions(-) diffs (29 lines): diff -r 08dc60979133 -r ac9b1df5b246 src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c Tue Apr 18 15:12:38 2017 +0300 +++ b/src/event/ngx_event_openssl.c Tue Apr 18 16:08:44 2017 +0300 @@ -837,7 +837,9 @@ ngx_ssl_info_callback(const ngx_ssl_conn BIO *rbio, *wbio; ngx_connection_t *c; -if (where & SSL_CB_HANDSHAKE_START) { +if ((where & SSL_CB_HANDSHAKE_START) +&& SSL_is_server((ngx_ssl_conn_t *) ssl_conn)) +{ c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); if (c->ssl->handshaked) { diff -r 08dc60979133 -r ac9b1df5b246 src/event/ngx_event_openssl.h --- a/src/event/ngx_event_openssl.h Tue Apr 18 15:12:38 2017 +0300 +++ b/src/event/ngx_event_openssl.h Tue Apr 18 16:08:44 2017 +0300 @@ -54,6 +54,11 @@ #define ngx_ssl_conn_t SSL +#if (OPENSSL_VERSION_NUMBER < 0x10002000L) +#define SSL_is_server(s)(s)->server +#endif + + struct ngx_ssl_s { SSL_CTX*ctx; ngx_log_t *log; ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] SSL: compatibility with OpenSSL master branch.
details: http://hg.nginx.org/nginx/rev/3518287d995e branches: changeset: 6983:3518287d995e user: Sergey Kandaurov date: Tue Apr 18 16:08:46 2017 +0300 description: SSL: compatibility with OpenSSL master branch. The SSL_CTRL_SET_CURVES_LIST macro is removed in the OpenSSL master branch. SSL_CTX_set1_curves_list is preserved as compatibility with previous versions. diffstat: src/event/ngx_event_openssl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ac9b1df5b246 -r 3518287d995e src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c Tue Apr 18 16:08:44 2017 +0300 +++ b/src/event/ngx_event_openssl.c Tue Apr 18 16:08:46 2017 +0300 @@ -1090,7 +1090,7 @@ ngx_ssl_ecdh_curve(ngx_conf_t *cf, ngx_s * maximum interoperability. */ -#ifdef SSL_CTRL_SET_CURVES_LIST +#if (defined SSL_CTX_set1_curves_list || defined SSL_CTRL_SET_CURVES_LIST) /* * OpenSSL 1.0.2+ allows configuring a curve list instead of a single ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] Sub filter: restored ngx_http_set_ctx() at the proper place.
details: http://hg.nginx.org/nginx/rev/201038680680 branches: changeset: 6984:201038680680 user: Sergey Kandaurov date: Tue Apr 18 19:55:23 2017 +0300 description: Sub filter: restored ngx_http_set_ctx() at the proper place. Previously, ngx_http_sub_header_filter() could fail with a partially initialized context, later accessed in ngx_http_sub_body_filter() if called from the perl content handler. The issue had appeared in 2c045e5b8291 (1.9.4). A better fix would be to handle ngx_http_send_header() errors in the perl module, though this doesn't seem to be easy enough. diffstat: src/http/modules/ngx_http_sub_filter_module.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 3518287d995e -r 201038680680 src/http/modules/ngx_http_sub_filter_module.c --- a/src/http/modules/ngx_http_sub_filter_module.c Tue Apr 18 16:08:46 2017 +0300 +++ b/src/http/modules/ngx_http_sub_filter_module.c Tue Apr 18 19:55:23 2017 +0300 @@ -248,8 +248,6 @@ ngx_http_sub_header_filter(ngx_http_requ ctx->matches->nelts); } -ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module); - ctx->saved.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1); if (ctx->saved.data == NULL) { return NGX_ERROR; @@ -260,6 +258,8 @@ ngx_http_sub_header_filter(ngx_http_requ return NGX_ERROR; } +ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module); + ctx->offset = ctx->tables->min_match_len - 1; ctx->last_out = &ctx->out; ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
crash in ngx_add_timer
Hi, I am new to NGinx modules and I trying to write an nginx module. I am having an issue where my module crashes when adding multiple timers. The first timer adds fine. However, when I go to add the second timer, it crashes. I've simplified the code to a very basic module (which is attached to this email). The backtrace is provided as well. Do I need to do some sort of initialization before I add multiple timers. Any advice/help is appreciated. Thanks. Dk. Program received signal SIGSEGV, Segmentation fault. 0x in ?? () (gdb) bt #0 0x in ?? () #1 0x0040d68b in ngx_rbtree_insert (tree=0x69dda0 , node=node@entry=0x69db08 ) at src/core/ngx_rbtree.c:44 #2 0x0046ceb2 in ngx_event_add_timer (timer=6, ev=0x69dae0 ) at src/event/ngx_event_timer.h:84 #3 ngx_test_init (cf=) at /home/ubuntu/git/mitigator/nginx/build/../modules/nginx_mitigator_module/platform/nginx-test-module.c:81 #4 0x00424e83 in ngx_http_block (cf=0x7fffe0a0, cmd=, conf=) at src/http/ngx_http.c:315 #5 0x0041446b in ngx_conf_handler (last=1, cf=0x7fffe0a0) at src/core/ngx_conf_file.c:427 #6 ngx_conf_parse (cf=cf@entry=0x7fffe0a0, filename=filename@entry =0x6ad570) at src/core/ngx_conf_file.c:283 #7 0x00411e1a in ngx_init_cycle (old_cycle=old_cycle@entry =0x7fffe260) at src/core/ngx_cycle.c:268 #8 0x00404208 in main (argc=, argv=) at src/core/nginx.c:268 (gdb) #include #include #include #include #include static ngx_event_t ev1; static ngx_event_t ev2; static ngx_event_t ev3; char ev1_data[] = "event1"; char ev2_data[] = "event2"; char ev3_data[] = "event3"; static ngx_int_t ngx_test_handler(ngx_http_request_t *r) { if (r->main->internal) { return NGX_DECLINED; } r->main->internal = 1; ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.headers); h->hash = 1; ngx_str_set(&h->key, "X-NGINX-Test"); ngx_str_set(&h->value, "Hello World!"); return NGX_DECLINED; } static void ev1_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev1, 5); } static void ev2_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev2, 6); } static void ev3_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev3, 7); } static ngx_int_t ngx_test_init (ngx_conf_t *cf) { ngx_http_handler_pt *h; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { ngx_log_error(NGX_LOG_ERR, cf->log, 0, "Cannot retrieve Nginx access handler pointer"); return NGX_ERROR; } *h = ngx_test_handler; ngx_log_error(NGX_LOG_INFO, cf->log, 0, "[test] Installed test handler"); ev1.handler = ev1_handler; ev1.data = ev1_data; ev2.handler = ev2_handler; ev2.data = ev2_data; ev3.handler = ev3_handler; ev3.data = ev3_data; ngx_add_timer(&ev1, 5); ngx_add_timer(&ev2, 6); ngx_add_timer(&ev3, 7); return NGX_OK; } static char * parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; if (cf->args->nelts != 2) { ngx_log_error(NGX_LOG_ERR, cf->log, 0 , "[ss-config] invalid params for config_file. Expected 2 received %d" , cf->args->nelts); return NGX_CONF_ERROR; } value = cf->args->elts; ngx_log_error(NGX_LOG_ERR, cf->log, 0, "file-path: %V", &value[1]); return NGX_CONF_OK; } static ngx_http_module_t ngx_test_module_ctx = { NULL, /* preconfiguration */ ngx_test_init, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL, /* create location configuration */ NULL /* merge location configuration */ }; static ngx_command_t ngx_test_module_cmds[] = { { ngx_string("config_file"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, parse_test_configuration, 0, 0, NULL } , ngx_null_command }; ngx_module_t nginx_test_module = { NGX_MODULE_V1, &ngx_test_module_ctx, /* module context */ ngx_test_module_cmds, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL,/* init master */ NULL,/* init module */ NULL,/* init process */ NULL,/* init thread */ NULL,/* exit thread */ NULL,
Re: crash in ngx_add_timer
resending since the attachment which had the code didn't make it... Dk. #include #include #include #include #include static ngx_event_t ev1; static ngx_event_t ev2; static ngx_event_t ev3; char ev1_data[] = "event1"; char ev2_data[] = "event2"; char ev3_data[] = "event3"; static ngx_int_t ngx_test_handler(ngx_http_request_t *r) { if (r->main->internal) { return NGX_DECLINED; } r->main->internal = 1; ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.headers); h->hash = 1; ngx_str_set(&h->key, "X-NGINX-Test"); ngx_str_set(&h->value, "Hello World!"); return NGX_DECLINED; } static void ev1_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev1, 5); } static void ev2_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev2, 6); } static void ev3_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev3, 7); } static ngx_int_t ngx_test_init (ngx_conf_t *cf) { ngx_http_handler_pt *h; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { ngx_log_error(NGX_LOG_ERR, cf->log, 0, "Cannot retrieve Nginx access handler pointer"); return NGX_ERROR; } *h = ngx_test_handler; ngx_log_error(NGX_LOG_INFO, cf->log, 0, "[test] Installed test handler"); ev1.handler = ev1_handler; ev1.data = ev1_data; ev2.handler = ev2_handler; ev2.data = ev2_data; ev3.handler = ev3_handler; ev3.data = ev3_data; ngx_add_timer(&ev1, 5); ngx_add_timer(&ev2, 6); ngx_add_timer(&ev3, 7); return NGX_OK; } static char * parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; if (cf->args->nelts != 2) { ngx_log_error(NGX_LOG_ERR, cf->log, 0 , "[ss-config] invalid params for config_file. Expected 2 received %d" , cf->args->nelts); return NGX_CONF_ERROR; } value = cf->args->elts; ngx_log_error(NGX_LOG_ERR, cf->log, 0, "file-path: %V", &value[1]); return NGX_CONF_OK; } static ngx_http_module_t ngx_test_module_ctx = { NULL, /* preconfiguration */ ngx_test_init, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL, /* create location configuration */ NULL /* merge location configuration */ }; static ngx_command_t ngx_test_module_cmds[] = { { ngx_string("config_file"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, parse_test_configuration, 0, 0, NULL } , ngx_null_command }; ngx_module_t nginx_test_module = { NGX_MODULE_V1, &ngx_test_module_ctx, /* module context */ ngx_test_module_cmds, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL,/* init master */ NULL,/* init module */ NULL,/* init process */ NULL,/* init thread */ NULL,/* exit thread */ NULL,/* exit process */ NULL,/* exit master */ NGX_MODULE_V1_PADDING }; On Tue, Apr 18, 2017 at 5:12 PM, Dk Jack wrote: > Hi, > I am new to NGinx modules and I trying to write an nginx module. I am > having an issue > where my module crashes when adding multiple timers. The first timer adds > fine. > However, when I go to add the second timer, it crashes. I've simplified > the code to a very > basic module (which is attached to this email). The backtrace is provided > as well. > Do I need to do some sort of initialization before I add multiple timers. > Any advice/help > is appreciated. Thanks. > > Dk. > > Program received signal SIGSEGV, Segmentation fault. > 0x in ?? () > (gdb) bt > #0 0x in ?? () > #1 0x0040d68b in ngx_rbtree_insert (tree=0x69dda0 > , > node=node@entry=0x69db08 ) at src/core/ngx_rbtree.c:44 > #2 0x0046ceb2 in ngx_event_add_timer (timer=6, ev=0x69dae0 ) > at src/event/ngx_event_timer.h:84 > #3 ngx_test_init (cf=) > at /home/ubuntu/git/mitigator/nginx/build/../modules/nginx_ > mitigator_module/platform/nginx-test-module.c:81 > #4 0x00424e83 in ngx_http_block (cf=0x7fffe0a0, > cmd=, > conf=) at src/http/ngx_http.c:315 > #5 0x0041446b in ngx_conf_handler (last=1, cf=0x7fffe0a0) > at src/core/ngx_conf_file.c:427 > #6 ngx_conf_parse (cf=cf@entry=0x7fffe0a0, filenam
Re: crash in ngx_add_timer
Hi, At the first glance, the ev->log should be assigned a valid value. -- Original -- From: "Dk Jack";; Send time: Wednesday, Apr 19, 2017 8:23 AM To: "nginx-devel"; Subject: Re: crash in ngx_add_timer resending since the attachment which had the code didn't make it... Dk. #include #include #include #include #include static ngx_event_t ev1; static ngx_event_t ev2; static ngx_event_t ev3; char ev1_data[] = "event1"; char ev2_data[] = "event2"; char ev3_data[] = "event3"; static ngx_int_t ngx_test_handler(ngx_http_request_t *r) { if (r->main->internal) { return NGX_DECLINED; } r->main->internal = 1; ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.headers); h->hash = 1; ngx_str_set(&h->key, "X-NGINX-Test"); ngx_str_set(&h->value, "Hello World!"); return NGX_DECLINED; } static void ev1_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev1, 5); } static void ev2_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev2, 6); } static void ev3_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev3, 7); } static ngx_int_t ngx_test_init (ngx_conf_t *cf) { ngx_http_handler_pt *h; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { ngx_log_error(NGX_LOG_ERR, cf->log, 0, "Cannot retrieve Nginx access handler pointer"); return NGX_ERROR; } *h = ngx_test_handler; ngx_log_error(NGX_LOG_INFO, cf->log, 0, "[test] Installed test handler"); ev1.handler = ev1_handler; ev1.data = ev1_data; ev2.handler = ev2_handler; ev2.data = ev2_data; ev3.handler = ev3_handler; ev3.data = ev3_data; ngx_add_timer(&ev1, 5); ngx_add_timer(&ev2, 6); ngx_add_timer(&ev3, 7); return NGX_OK; } static char * parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; if (cf->args->nelts != 2) { ngx_log_error(NGX_LOG_ERR, cf->log, 0 , "[ss-config] invalid params for config_file. Expected 2 received %d" , cf->args->nelts); return NGX_CONF_ERROR; } value = cf->args->elts; ngx_log_error(NGX_LOG_ERR, cf->log, 0, "file-path: %V", &value[1]); return NGX_CONF_OK; } static ngx_http_module_t ngx_test_module_ctx = { NULL, /* preconfiguration */ ngx_test_init,/* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL, /* create location configuration */ NULL /* merge location configuration */ }; static ngx_command_t ngx_test_module_cmds[] = { { ngx_string("config_file"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, parse_test_configuration, 0, 0, NULL } , ngx_null_command }; ngx_module_t nginx_test_module = { NGX_MODULE_V1, &ngx_test_module_ctx, /* module context */ ngx_test_module_cmds, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL,/* init master */ NULL,/* init module */ NULL,/* init process */ NULL,/* init thread */ NULL,/* exit thread */ NULL,/* exit process */ NULL,/* exit master */ NGX_MODULE_V1_PADDING }; On Tue, Apr 18, 2017 at 5:12 PM, Dk Jack wrote: Hi,I am new to NGinx modules and I trying to write an nginx module. I am having an issue where my module crashes when adding multiple timers. The first timer adds fine. However, when I go to add the second timer, it crashes. I've simplified the code to a very basic module (which is attached to this email). The backtrace is provided as well. Do I need to do some sort of initialization before I add multiple timers. Any advice/help is appreciated. Thanks. Dk. Program received signal SIGSEGV, Segmentation fault. 0x in ?? () (gdb) bt #0 0x in ?? () #1 0x0040d68b in ngx_rbtree_insert (tree=0x69dda0 , node=node@entry=0x69db08 ) at src/core/ngx_rbtree.
Re: crash in ngx_add_timer
Hi, The crash is happening at line: ngx_add_timer(&ev2, 6);// line 81 i.e. when it's trying to insert the second time. It doesn't even get to the handler. What would be a good value to assign to ev->log? I added: ev->log = cf->cycle->log I am still getting the crash when I try to insert the second timer. On Tue, Apr 18, 2017 at 6:53 PM, 胡聪 (hucc) wrote: > Hi, > > At the first glance, the ev->log should be assigned a valid value. > > > -- Original -- > *From: * "Dk Jack";; > *Send time:* Wednesday, Apr 19, 2017 8:23 AM > *To:* "nginx-devel"; > *Subject: * Re: crash in ngx_add_timer > > resending since the attachment which had the code didn't make it... > > Dk. > > #include > #include > #include > #include > #include > > static ngx_event_t ev1; > static ngx_event_t ev2; > static ngx_event_t ev3; > > char ev1_data[] = "event1"; > char ev2_data[] = "event2"; > char ev3_data[] = "event3"; > > static ngx_int_t > ngx_test_handler(ngx_http_request_t *r) > { > if (r->main->internal) { > return NGX_DECLINED; > } > > r->main->internal = 1; > > ngx_table_elt_t *h; > h = ngx_list_push(&r->headers_out.headers); > h->hash = 1; > ngx_str_set(&h->key, "X-NGINX-Test"); > ngx_str_set(&h->value, "Hello World!"); > > return NGX_DECLINED; > } > > static void > ev1_handler(ngx_event_t* ev) > { > ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) > ev->data); > ngx_add_timer(&ev1, 5); > } > > static void > ev2_handler(ngx_event_t* ev) > { > ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) > ev->data); > ngx_add_timer(&ev2, 6); > } > > static void > ev3_handler(ngx_event_t* ev) > { > ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) > ev->data); > ngx_add_timer(&ev3, 7); > } > > static ngx_int_t > ngx_test_init (ngx_conf_t *cf) > { > ngx_http_handler_pt *h; > ngx_http_core_main_conf_t *cmcf; > > cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); > h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); > > if (h == NULL) { > ngx_log_error(NGX_LOG_ERR, cf->log, 0, "Cannot retrieve Nginx access > handler pointer"); > return NGX_ERROR; > } > > *h = ngx_test_handler; > ngx_log_error(NGX_LOG_INFO, cf->log, 0, "[test] Installed test handler"); > > ev1.handler = ev1_handler; > ev1.data = ev1_data; > > ev2.handler = ev2_handler; > ev2.data = ev2_data; > > ev3.handler = ev3_handler; > ev3.data = ev3_data; > > ngx_add_timer(&ev1, 5); > ngx_add_timer(&ev2, 6); > ngx_add_timer(&ev3, 7); > > return NGX_OK; > } > > static char * > parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) > { > ngx_str_t *value; > > if (cf->args->nelts != 2) { > ngx_log_error(NGX_LOG_ERR, cf->log, 0 > , "[ss-config] invalid params for config_file. Expected > 2 received %d" > , cf->args->nelts); > return NGX_CONF_ERROR; > } > > value = cf->args->elts; > > ngx_log_error(NGX_LOG_ERR, cf->log, 0, "file-path: %V", &value[1]); > > return NGX_CONF_OK; > } > > > static ngx_http_module_t ngx_test_module_ctx = { > NULL, /* preconfiguration */ > ngx_test_init, /* postconfiguration */ > NULL, /* create main configuration */ > NULL, /* init main configuration */ > NULL, /* create server configuration */ > NULL, /* merge server configuration */ > NULL, /* create location configuration */ > NULL /* merge location configuration */ > }; > > static ngx_command_t ngx_test_module_cmds[] = { > { > ngx_string("config_file"), > NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, > parse_test_configuration, > 0, > 0, > NULL > } > , ngx_null_command > }; > > ngx_module_t nginx_test_module = { > NGX_MODULE_V1, > &ngx_test_module_ctx, /* module context */ > ngx_test_module_cmds, /* module directives */ > NGX_HTTP_MODULE, /* module type */ > NULL,/* init master */ > NULL,/* init module */ > NULL,/* init process */ > NULL,/* init thread */ > NULL,/* exit thread */ > NULL,/* exit process */ > NULL,/* exit master */ > NGX_MODULE_V1_PADDING > }; > > > On Tue, Apr 18, 2017 at 5:12 PM, Dk Jack wrote: > >> Hi, >> I am new to NGinx modules and I trying to write an nginx module. I am >> having an issue >> where my module crashes when adding multiple timers. The first timer adds >> fine. >> However, when I go to add the second timer, it crashes. I've simplified >> the code to a very >> basic module (which is attached to this email). The backtrace is provided >> as wel
Re: crash in ngx_add_timer
Hi, U should not call ngx_add_timer there, causengx_event_timer_rbtree is initialized in [init process]. Ben best regards Original Message Sender:Dk jackdnj0...@gmail.com Recipient:nginx-devel@nginx.orgnginx-de...@nginx.org Date:Wednesday, Apr 19, 2017 10:03 Subject:Re: crash in ngx_add_timer Hi, The crash is happening at line: ngx_add_timer(ev2, 6); // line 81 i.e. when it's trying to insert the second time. It doesn't even get to the handler. What would be a good value to assign to ev-log? I added: ev-log = cf-cycle-log I am still getting the crash when I try to insert the second timer. On Tue, Apr 18, 2017 at 6:53 PM, 胡聪 (hucc) hucon...@foxmail.com wrote: Hi, At the first glance, the ev-log should be assigned a valid value. --Original-- From: "Dk Jack";dnj0...@gmail.com; Send time:Wednesday, Apr 19, 2017 8:23 AM To:"nginx-devel"nginx-devel@nginx.org; Subject: Re: crash in ngx_add_timer resending since the attachment which had the code didn't make it... Dk. #include assert.h #include nginx.h #include ngx_config.h #include ngx_core.h #include ngx_http.h static ngx_event_t ev1; static ngx_event_t ev2; static ngx_event_t ev3; char ev1_data[] = "event1"; char ev2_data[] = "event2"; char ev3_data[] = "event3"; static ngx_int_t ngx_test_handler(ngx_http_request_t *r) { if (r-main-internal) { return NGX_DECLINED; } r-main-internal = 1; ngx_table_elt_t *h; h = ngx_list_push(r-headers_out.headers); h-hash = 1; ngx_str_set(h-key, "X-NGINX-Test"); ngx_str_set(h-value, "Hello World!"); return NGX_DECLINED; } static void ev1_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev-log, 0, "received event: %s", (char *) ev-data); ngx_add_timer(ev1, 5); } static void ev2_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev-log, 0, "received event: %s", (char *) ev-data); ngx_add_timer(ev2, 6); } static void ev3_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev-log, 0, "received event: %s", (char *) ev-data); ngx_add_timer(ev3, 7); } static ngx_int_t ngx_test_init (ngx_conf_t *cf) { ngx_http_handler_pt *h; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); h = ngx_array_push(cmcf-phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { ngx_log_error(NGX_LOG_ERR, cf-log, 0, "Cannot retrieve Nginx access handler pointer"); return NGX_ERROR; } *h = ngx_test_handler; ngx_log_error(NGX_LOG_INFO, cf-log, 0, "[test] Installed test handler"); ev1.handler = ev1_handler; ev1.data = ev1_data; ev2.handler = ev2_handler; ev2.data = ev2_data; ev3.handler = ev3_handler; ev3.data = ev3_data; ngx_add_timer(ev1, 5); ngx_add_timer(ev2, 6); ngx_add_timer(ev3, 7); return NGX_OK; } static char * parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; if (cf-args-nelts != 2) { ngx_log_error(NGX_LOG_ERR, cf-log, 0 , "[ss-config] invalid params for config_file. Expected 2 received %d" , cf-args-nelts); return NGX_CONF_ERROR; } value = cf-args-elts; ngx_log_error(NGX_LOG_ERR, cf-log, 0, "file-path: %V", value[1]); return NGX_CONF_OK; } static ngx_http_module_t ngx_test_module_ctx = { NULL, /* preconfiguration */ ngx_test_init,/* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL,/* create location configuration */ NULL /* merge location configuration */ }; static ngx_command_t ngx_test_module_cmds[] = { { ngx_string("config_file"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, parse_test_configuration, 0, 0, NULL } , ngx_null_command }; ngx_module_t nginx_test_module = { NGX_MODULE_V1, ngx_test_module_ctx, /* module context */ ngx_test_module_cmds, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING }; On Tue, Apr 18, 2017 at 5:12 PM, Dk Jack dnj0...@gmail.com wrote: Hi, I am new to NGinx modules and I trying to write an nginx module. I am having an issue where my module crashes when adding multiple timers. The first timer adds fine. However, when I go to add the second timer, it crashes. I've simplified the code to a very basic module (which is attached to this email). The backtrace is provided as well. Do I need to do some sort of initialization before I add multiple timers. Any advice/help is appreciated. Thanks. Dk. Program received signal SIGSEGV, Segmentation fault. 0x0
Re: crash in ngx_add_timer
That`s right! I almost forgot that. -- Original -- From: "734819342";<734819...@qq.com>; Send time: Wednesday, Apr 19, 2017 10:23 AM To: "nginx-devel@nginx.org"; Subject: Re: crash in ngx_add_timer Hi, U should not call ngx_add_timer there, cause ngx_event_timer_rbtree is initialized in [init process]. Ben best regards Original Message Sender: Dk Jack Recipient: nginx-devel@nginx.org Date: Wednesday, Apr 19, 2017?10:03 Subject: Re: crash in ngx_add_timer Hi, The crash is happening at line: ngx_add_timer(&ev2, 6);// line 81 i.e. when it's trying to insert the second time. It doesn't even get to the handler. What would be a good value to assign to ev->log? I added: ev->log = cf->cycle->log I am still getting the crash when I try to insert the second timer. On Tue, Apr 18, 2017 at 6:53 PM, 胡聪 (hucc) wrote: Hi, At the first glance, the ev->log should be assigned a valid value. -- Original -- From: "Dk Jack";; Send time: Wednesday, Apr 19, 2017 8:23 AM To: "nginx-devel"; Subject: Re: crash in ngx_add_timer resending since the attachment which had the code didn't make it... Dk. #include #include #include #include #include static ngx_event_t ev1; static ngx_event_t ev2; static ngx_event_t ev3; char ev1_data[] = "event1"; char ev2_data[] = "event2"; char ev3_data[] = "event3"; static ngx_int_t ngx_test_handler(ngx_http_request_t *r) { if (r->main->internal) { return NGX_DECLINED; } r->main->internal = 1; ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.headers); h->hash = 1; ngx_str_set(&h->key, "X-NGINX-Test"); ngx_str_set(&h->value, "Hello World!"); return NGX_DECLINED; } static void ev1_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev1, 5); } static void ev2_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev2, 6); } static void ev3_handler(ngx_event_t* ev) { ngx_log_error(NGX_LOG_ERR, ev->log, 0, "received event: %s", (char *) ev->data); ngx_add_timer(&ev3, 7); } static ngx_int_t ngx_test_init (ngx_conf_t *cf) { ngx_http_handler_pt *h; ngx_http_core_main_conf_t *cmcf; cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { ngx_log_error(NGX_LOG_ERR, cf->log, 0, "Cannot retrieve Nginx access handler pointer"); return NGX_ERROR; } *h = ngx_test_handler; ngx_log_error(NGX_LOG_INFO, cf->log, 0, "[test] Installed test handler"); ev1.handler = ev1_handler; ev1.data = ev1_data; ev2.handler = ev2_handler; ev2.data = ev2_data; ev3.handler = ev3_handler; ev3.data = ev3_data; ngx_add_timer(&ev1, 5); ngx_add_timer(&ev2, 6); ngx_add_timer(&ev3, 7); return NGX_OK; } static char * parse_test_configuration (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; if (cf->args->nelts != 2) { ngx_log_error(NGX_LOG_ERR, cf->log, 0 , "[ss-config] invalid params for config_file. Expected 2 received %d" , cf->args->nelts); return NGX_CONF_ERROR; } value = cf->args->elts; ngx_log_error(NGX_LOG_ERR, cf->log, 0, "file-path: %V", &value[1]); return NGX_CONF_OK; } static ngx_http_module_t ngx_test_module_ctx = { NULL, /* preconfiguration */ ngx_test_init, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL,/* create location configuration */ NULL /* merge location configuration */ }; static ngx_command_t ngx_test_module_cmds[] = { { ngx_string("config_file"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, parse_test_configuration, 0, 0, NULL } , ngx_null_command }; ngx_module_t nginx_test_module = { NGX_MODULE_V1, &ngx_test_module_ctx, /* module context */ ngx_test_module_cmds, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL,/* init master */ NULL,/* init module */ NULL,/* init process */ NULL,/* init thread */ NULL,