From ade53e70bcfb5f23b6b3e1c8f083eb24633d8c2b Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Wed, 16 Nov 2011 21:10:19 +0000 Subject: [PATCH] Backport r1202886: Avoid one apr_time_now() call in the fast path git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1202887 13f79535-47bb-0310-9956-ffa450edef68 --- modules/filters/mod_reqtimeout.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/filters/mod_reqtimeout.c b/modules/filters/mod_reqtimeout.c index 800bb6b4a9..5e10b4ca3f 100644 --- a/modules/filters/mod_reqtimeout.c +++ b/modules/filters/mod_reqtimeout.c @@ -85,9 +85,12 @@ static void extend_timeout(reqtimeout_con_cfg *ccfg, apr_bucket_brigade *bb) } static apr_status_t check_time_left(reqtimeout_con_cfg *ccfg, - apr_time_t *time_left_p) + apr_time_t *time_left_p, + apr_time_t now) { - *time_left_p = ccfg->timeout_at - apr_time_now(); + if (!now) + now = apr_time_now(); + *time_left_p = ccfg->timeout_at - now; if (*time_left_p <= 0) return APR_TIMEUP; @@ -169,7 +172,7 @@ static apr_status_t reqtimeout_filter(ap_filter_t *f, apr_off_t readbytes) { apr_time_t time_left; - apr_time_t now; + apr_time_t now = 0; apr_status_t rv; apr_interval_time_t saved_sock_timeout = UNSET; reqtimeout_con_cfg *ccfg = f->ctx; @@ -180,9 +183,9 @@ static apr_status_t reqtimeout_filter(ap_filter_t *f, return ap_get_brigade(f->next, bb, mode, block, readbytes); } - now = apr_time_now(); if (ccfg->new_timeout > 0) { /* set new timeout */ + now = apr_time_now(); ccfg->timeout_at = now + apr_time_from_sec(ccfg->new_timeout); ccfg->new_timeout = 0; if (ccfg->new_max_timeout > 0) { @@ -199,7 +202,7 @@ static apr_status_t reqtimeout_filter(ap_filter_t *f, ccfg->socket = ap_get_conn_socket(f->c); } - rv = check_time_left(ccfg, &time_left); + rv = check_time_left(ccfg, &time_left, now); if (rv != APR_SUCCESS) goto out; @@ -281,7 +284,7 @@ static apr_status_t reqtimeout_filter(ap_filter_t *f, if (rv != APR_SUCCESS) break; - rv = check_time_left(ccfg, &time_left); + rv = check_time_left(ccfg, &time_left, 0); if (rv != APR_SUCCESS) break; -- 2.40.0