Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed on-demand hander/filter registration trick for HUP.

  • Loading branch information...
commit 9057b099160cfa103db3b0cf1e3efd8798a189bf 1 parent 936a555
@agentzh agentzh authored
View
30 src/ngx_http_headers_more_filter_module.c
@@ -11,20 +11,18 @@
#include <ngx_config.h>
-ngx_flag_t ngx_http_headers_more_access_input_headers = 0;
+unsigned ngx_http_headers_more_handler_used = 0;
+unsigned ngx_http_headers_more_filter_used = 0;
-ngx_flag_t ngx_http_headers_more_access_output_headers = 0;
/* config handlers */
static void * ngx_http_headers_more_create_loc_conf(ngx_conf_t *cf);
-
static char * ngx_http_headers_more_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
-
static void * ngx_http_headers_more_create_main_conf(ngx_conf_t *cf);
-
static ngx_int_t ngx_http_headers_more_post_config(ngx_conf_t *cf);
+static ngx_int_t ngx_http_headers_more_pre_config(ngx_conf_t *cf);
/* post-read-phase handler */
@@ -34,6 +32,7 @@ static ngx_int_t ngx_http_headers_more_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_headers_more_filter_init(ngx_conf_t *cf);
+
static ngx_command_t ngx_http_headers_more_filter_commands[] = {
{ ngx_string("more_set_headers"),
@@ -72,7 +71,7 @@ static ngx_command_t ngx_http_headers_more_filter_commands[] = {
};
static ngx_http_module_t ngx_http_headers_more_filter_module_ctx = {
- NULL, /* preconfiguration */
+ ngx_http_headers_more_pre_config, /* preconfiguration */
ngx_http_headers_more_post_config, /* postconfiguration */
ngx_http_headers_more_create_main_conf, /* create main configuration */
@@ -112,6 +111,9 @@ ngx_http_headers_more_filter(ngx_http_request_t *r)
ngx_http_headers_more_loc_conf_t *conf;
ngx_http_headers_more_cmd_t *cmd;
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "headers more header filter, uri \"%V\"", &r->uri);
+
conf = ngx_http_get_module_loc_conf(r, ngx_http_headers_more_filter_module);
if (conf->cmds) {
@@ -204,14 +206,14 @@ ngx_http_headers_more_post_config(ngx_conf_t *cf)
ngx_http_core_main_conf_t *cmcf;
ngx_int_t rc;
- if (ngx_http_headers_more_access_output_headers) {
+ if (ngx_http_headers_more_filter_used) {
rc = ngx_http_headers_more_filter_init(cf);
if (rc != NGX_OK) {
return rc;
}
}
- if ( ! ngx_http_headers_more_access_input_headers ) {
+ if (!ngx_http_headers_more_handler_used) {
return NGX_OK;
}
@@ -237,6 +239,9 @@ ngx_http_headers_more_handler(ngx_http_request_t *r)
ngx_http_headers_more_main_conf_t *hmcf;
ngx_http_headers_more_cmd_t *cmd;
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "headers more rewrite handler, uri \"%V\"", &r->uri);
+
hmcf = ngx_http_get_module_main_conf(r,
ngx_http_headers_more_filter_module);
@@ -311,3 +316,12 @@ ngx_http_headers_more_create_main_conf(ngx_conf_t *cf)
return hmcf;
}
+
+static ngx_int_t
+ngx_http_headers_more_pre_config(ngx_conf_t *cf)
+{
+ ngx_http_headers_more_handler_used = 0;
+ ngx_http_headers_more_filter_used = 0;
+ return NGX_OK;
+}
+
View
4 src/ngx_http_headers_more_filter_module.h
@@ -58,8 +58,8 @@ struct ngx_http_headers_more_header_val_s {
extern ngx_module_t ngx_http_headers_more_filter_module;
-extern ngx_flag_t ngx_http_headers_more_access_input_headers;
-extern ngx_flag_t ngx_http_headers_more_access_output_headers;
+extern unsigned ngx_http_headers_more_handler_used;
+extern unsigned ngx_http_headers_more_filter_used;
#endif /* NGX_HTTP_HEADERS_MORE_FILTER_MODULE_H */
View
2  src/ngx_http_headers_more_headers_in.c
@@ -549,7 +549,7 @@ ngx_http_headers_more_parse_directive(ngx_conf_t *cf, ngx_command_t *ngx_cmd,
cmd->is_input = 1;
- ngx_http_headers_more_access_input_headers = 1;
+ ngx_http_headers_more_handler_used = 1;
return NGX_CONF_OK;
}
View
5 src/ngx_http_headers_more_headers_out.c
@@ -114,7 +114,7 @@ ngx_http_headers_more_exec_cmd(ngx_http_request_t *r,
ngx_http_headers_more_cmd_t *cmd)
{
ngx_str_t value;
- ngx_http_headers_more_header_val_t *h;
+ ngx_http_headers_more_header_val_t *h;
ngx_uint_t i;
if (!cmd->headers) {
@@ -572,6 +572,7 @@ ngx_http_headers_more_parse_directive(ngx_conf_t *cf, ngx_command_t *ngx_cmd,
ignore_next_arg = 1;
continue;
+
} else if (arg[i].data[1] == 's') {
if (i == cf->args->nelts - 1) {
ngx_log_error(NGX_LOG_ERR, cf->log, 0,
@@ -620,7 +621,7 @@ ngx_http_headers_more_parse_directive(ngx_conf_t *cf, ngx_command_t *ngx_cmd,
cmd->is_input = 0;
- ngx_http_headers_more_access_output_headers = 1;
+ ngx_http_headers_more_filter_used = 1;
return NGX_CONF_OK;
}
View
2  util/build.sh
@@ -22,8 +22,8 @@ ngx-build $force $version \
--add-module=$root/../eval-nginx-module \
--add-module=$root/../echo-nginx-module \
--add-module=$root $opts \
+ --with-debug \
|| exit 1
- #--with-debug \
#--add-module=$root/../ndk-nginx-module \
#--without-http_ssi_module # we cannot disable ssi because echo_location_async depends on it (i dunno why?!)
View
39 valgrind.suppress
@@ -1,4 +1,43 @@
{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ fun:ngx_alloc
+ fun:ngx_create_pool
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ fun:ngx_alloc
+ fun:ngx_malloc
+ fun:ngx_palloc_large
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Cond
+ fun:memcpy
+ fun:ngx_vslprintf
+ fun:ngx_log_error_core
+ fun:ngx_http_charset_header_filter
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ fun:ngx_alloc
+ fun:ngx_malloc
+ fun:ngx_pnalloc
+}
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Leak
+ fun:malloc
+ fun:ngx_alloc
+ fun:ngx_malloc
+ fun:ngx_palloc
+}
+{
nginx-core-process-init
Memcheck:Leak
fun:malloc
Please sign in to comment.
Something went wrong with that request. Please try again.