From 7af68c0bf546ffe8aa86b9251258037eda6bc903 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 12 Jun 2002 23:59:31 +0000 Subject: Solve the 80/20 by initializing and storing server_rec->timeout and server_rec->keep_alive_timeout in apr_time_interval_t format (in apr units, whatever they be), as both values exist to pass into APR, and all APR timeouts are in apr_time_t. Reviewed by: Cliff Woolley git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95623 13f79535-47bb-0310-9956-ffa450edef68 --- modules/experimental/mod_ext_filter.c | 4 ++-- modules/generators/mod_cgi.c | 11 +++-------- modules/generators/mod_info.c | 3 ++- modules/http/http_core.c | 2 +- modules/http/http_protocol.c | 10 +++++----- modules/proxy/mod_proxy.c | 2 +- modules/proxy/proxy_ftp.c | 7 ++----- modules/proxy/proxy_util.c | 6 ++---- 8 files changed, 18 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/experimental/mod_ext_filter.c b/modules/experimental/mod_ext_filter.c index e7ddee2cbe..8e94408603 100644 --- a/modules/experimental/mod_ext_filter.c +++ b/modules/experimental/mod_ext_filter.c @@ -604,7 +604,7 @@ static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data, rv = apr_poll(ctx->pollset, &num_events, - f->r->server->timeout * APR_USEC_PER_SEC); + f->r->server->timeout); if (rv || dc->debug >= DBGLVL_GORY) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, "apr_poll()"); @@ -696,7 +696,7 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) * timeout; we don't care if we don't return from apr_file_read() for a while... */ rv = apr_file_pipe_timeout_set(ctx->proc->out, - r->server->timeout * APR_USEC_PER_SEC); + r->server->timeout); if (rv) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "apr_file_pipe_timeout_set(child output)"); diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 88e70ae207..daad028808 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -490,23 +490,18 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, *script_in = procnew->out; if (!*script_in) return APR_EBADF; - apr_file_pipe_timeout_set(*script_in, (int)(r->server->timeout * - APR_USEC_PER_SEC)); + apr_file_pipe_timeout_set(*script_in, r->server->timeout); if (e_info->prog_type == RUN_AS_CGI) { *script_out = procnew->in; if (!*script_out) return APR_EBADF; - apr_file_pipe_timeout_set(*script_out, - (int)(r->server->timeout * - APR_USEC_PER_SEC)); + apr_file_pipe_timeout_set(*script_out, r->server->timeout); *script_err = procnew->err; if (!*script_err) return APR_EBADF; - apr_file_pipe_timeout_set(*script_err, - (int)(r->server->timeout * - APR_USEC_PER_SEC)); + apr_file_pipe_timeout_set(*script_err, r->server->timeout); } } } diff --git a/modules/generators/mod_info.c b/modules/generators/mod_info.c index 3623155f72..f29b82f6f8 100644 --- a/modules/generators/mod_info.c +++ b/modules/generators/mod_info.c @@ -395,7 +395,8 @@ static int display_info(request_rec *r) ap_rprintf(r, "
Timeouts: " "connection: %d    " "keep-alive: %d
", - serv->timeout, serv->keep_alive_timeout); + (int)(apr_time_sec(serv->timeout)), + (int)(apr_time_sec(serv->timeout))); ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons); ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded); ap_mpm_query(AP_MPMQ_IS_FORKED, &forked); diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 854b7c9289..cc51aee644 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -91,7 +91,7 @@ static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy, return err; } - cmd->server->keep_alive_timeout = atoi(arg); + cmd->server->keep_alive_timeout = apr_time_from_sec(atoi(arg)); return NULL; } diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index cab3bafe0c..7a1f4e8e7a 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -254,14 +254,14 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r) if (ka_sent) { if (r->server->keep_alive_max) { apr_table_setn(r->headers_out, "Keep-Alive", - apr_psprintf(r->pool, "timeout=%d, max=%d", - r->server->keep_alive_timeout, - left)); + apr_psprintf(r->pool, "timeout=%d, max=%d", + (int)apr_time_sec(r->server->keep_alive_timeout), + left)); } else { apr_table_setn(r->headers_out, "Keep-Alive", - apr_psprintf(r->pool, "timeout=%d", - r->server->keep_alive_timeout)); + apr_psprintf(r->pool, "timeout=%d", + (int)apr_time_sec(r->server->keep_alive_timeout))); } apr_table_mergen(r->headers_out, "Connection", "Keep-Alive"); } diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 513c82045c..e78415aae3 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -886,7 +886,7 @@ static const char* return "Proxy Timeout must be at least 1 second."; } psf->timeout_set=1; - psf->timeout=timeout; + psf->timeout=apr_time_from_sec(timeout); return NULL; } diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index 93b5582fe2..4bbcaf679e 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -968,14 +968,11 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf, /* Set a timeout on the socket */ if (conf->timeout_set == 1) { - apr_setsocketopt(sock, - APR_SO_TIMEOUT, - (int)(conf->timeout * APR_USEC_PER_SEC)); + apr_setsocketopt(sock, APR_SO_TIMEOUT, conf->timeout); } else { apr_setsocketopt(sock, - APR_SO_TIMEOUT, - (int)(r->server->timeout * APR_USEC_PER_SEC)); + APR_SO_TIMEOUT, r->server->timeout); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 355e51bad8..94106f8c9c 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1158,12 +1158,10 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock, /* Set a timeout on the socket */ if (conf->timeout_set == 1) { - apr_setsocketopt(*newsock, APR_SO_TIMEOUT, - (int)(conf->timeout * APR_USEC_PER_SEC)); + apr_setsocketopt(*newsock, APR_SO_TIMEOUT, conf->timeout); } else { - apr_setsocketopt(*newsock, APR_SO_TIMEOUT, - (int)(s->timeout * APR_USEC_PER_SEC)); + apr_setsocketopt(*newsock, APR_SO_TIMEOUT, s->timeout); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, -- cgit v1.2.1