diff --git a/src/ngx_postgres_ddebug.h b/src/ngx_postgres_ddebug.h index 7cc05ecd..38253fca 100644 --- a/src/ngx_postgres_ddebug.h +++ b/src/ngx_postgres_ddebug.h @@ -29,6 +29,7 @@ #ifndef _NGX_POSTGRES_DDEBUG_H_ #define _NGX_POSTGRES_DDEBUG_H_ +#include #include #if defined(DDEBUG) && (DDEBUG) diff --git a/src/ngx_postgres_output.c b/src/ngx_postgres_output.c index 81a0b275..9fa5481c 100644 --- a/src/ngx_postgres_output.c +++ b/src/ngx_postgres_output.c @@ -549,7 +549,7 @@ ngx_postgres_output_chain(ngx_http_request_t *r, ngx_chain_t *cl) pglcf = ngx_http_get_module_loc_conf(r, ngx_postgres_module); pgctx = ngx_http_get_module_ctx(r, ngx_postgres_module); - r->headers_out.status = pgctx->status ? abs(pgctx->status) + r->headers_out.status = pgctx->status ? ngx_abs(pgctx->status) : NGX_HTTP_OK; if (pglcf->output_handler == &ngx_postgres_output_rds) { diff --git a/src/ngx_postgres_util.c b/src/ngx_postgres_util.c index 11b27979..ae7de38c 100644 --- a/src/ngx_postgres_util.c +++ b/src/ngx_postgres_util.c @@ -45,7 +45,9 @@ void ngx_postgres_upstream_finalize_request(ngx_http_request_t *r, ngx_http_upstream_t *u, ngx_int_t rc) { +#if defined(nginx_version) && (nginx_version < 1009001) ngx_time_t *tp; +#endif dd("entering"); @@ -61,10 +63,15 @@ ngx_postgres_upstream_finalize_request(ngx_http_request_t *r, u->resolved->ctx = NULL; } +#if defined(nginx_version) && (nginx_version >= 1009001) + if (u->state && u->state->response_time) { + u->state->response_time = ngx_current_msec - u->state->response_time; +#else if (u->state && u->state->response_sec) { tp = ngx_timeofday(); u->state->response_sec = tp->sec - u->state->response_sec; u->state->response_msec = tp->msec - u->state->response_msec; +#endif if (u->pipe) { u->state->response_length = u->pipe->read_length;