diff --git a/patches/nginx-1.11.2-intercept_error_log.patch b/patches/nginx-1.11.2-intercept_error_log.patch new file mode 100644 index 0000000..5de7695 --- /dev/null +++ b/patches/nginx-1.11.2-intercept_error_log.patch @@ -0,0 +1,60 @@ +diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h +index c51b7ff..4c335b9 100644 +--- a/src/core/ngx_cycle.h ++++ b/src/core/ngx_cycle.h +@@ -22,9 +22,14 @@ + #define NGX_DEBUG_POINTS_ABORT 2 + + ++#define HAVE_INTERCEPT_ERROR_LOG_PATCH ++ ++ + typedef struct ngx_shm_zone_s ngx_shm_zone_t; + + typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data); ++typedef ngx_int_t (*ngx_log_intercept_pt) (ngx_log_t *log, ngx_uint_t level, ++ u_char *buf, size_t len); + + struct ngx_shm_zone_s { + void *data; +@@ -75,6 +80,10 @@ struct ngx_cycle_s { + ngx_str_t prefix; + ngx_str_t lock_file; + ngx_str_t hostname; ++ ++ ngx_log_intercept_pt intercept_error_log_handler; ++ void *intercept_error_log_data; ++ unsigned entered_logger; /* :1 */ + }; + + +diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c +index 8e9408d..ed9b11b 100644 +--- a/src/core/ngx_log.c ++++ b/src/core/ngx_log.c +@@ -112,6 +112,8 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, + ngx_uint_t wrote_stderr, debug_connection; + u_char errstr[NGX_MAX_ERROR_STR]; + ++ ngx_log_intercept_pt log_intercept = NULL; ++ + last = errstr + NGX_MAX_ERROR_STR; + + p = ngx_cpymem(errstr, ngx_cached_err_log_time.data, +@@ -153,6 +155,16 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, + p = last - NGX_LINEFEED_SIZE; + } + ++ if (ngx_cycle) { ++ log_intercept = ngx_cycle->intercept_error_log_handler; ++ } ++ ++ if (log_intercept && !ngx_cycle->entered_logger) { ++ ngx_cycle->entered_logger = 1; ++ log_intercept(log, level, errstr, p - errstr); ++ ngx_cycle->entered_logger = 0; ++ } ++ + ngx_linefeed(p); + + wrote_stderr = 0; diff --git a/util/mirror-tarballs b/util/mirror-tarballs index 4063980..29350d3 100755 --- a/util/mirror-tarballs +++ b/util/mirror-tarballs @@ -55,9 +55,19 @@ else fi fi -echo "$info_txt applying the privileged-agent-process patch" -patch -p1 < $root/patches/nginx-$main_ver-privileged_agent_process.patch || exit 1 -echo +answer=`$root/util/ver-ge "$main_ver" 1.11.2` +if [ "$answer" = "Y" ]; then + echo "$info_txt applying the privileged-agent-process patch" + patch -p1 < $root/patches/nginx-$main_ver-privileged_agent_process.patch || exit 1 + echo +fi + +answer=`$root/util/ver-ge "$main_ver" 1.11.2` +if [ "$answer" = "Y" ]; then + echo "$info_txt applying the intercept-error-log patch" + patch -p1 < $root/patches/nginx-$main_ver-intercept_error_log.patch || exit 1 + echo +fi echo "$info_txt applying the upstream-pipelining patch for nginx" patch -p1 < $root/patches/nginx-$main_ver-upstream_pipelining.patch || exit 1