From: William A. Rowe Jr Date: Mon, 15 Jul 2002 07:46:19 +0000 (+0000) Subject: Timeout/time fixes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee9682cf117a31b035345bec209c6ba4afb02b5f;p=apache Timeout/time fixes git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96055 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index fc44581c7f..e05a92812c 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -968,11 +968,10 @@ 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_socket_timeout_set(sock, conf->timeout); } else { - apr_setsocketopt(sock, - APR_SO_TIMEOUT, (int)r->server->timeout); + apr_socket_timeout_set(sock, r->server->timeout); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index f536ba47c8..bce637b2c2 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -319,7 +319,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r, apr_size_t buffer_len = 1; char test_buffer[1]; apr_status_t socket_status; - apr_short_interval_time_t current_timeout; + apr_interval_time_t current_timeout; /* use previous keepalive socket */ *origin = backend->connection; @@ -327,12 +327,12 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r, new = 0; /* save timeout */ - apr_getsocketopt(p_conn->sock, APR_SO_TIMEOUT, ¤t_timeout); + apr_socket_timeout_get(p_conn->sock, ¤t_timeout); /* set no timeout */ - apr_setsocketopt(p_conn->sock, APR_SO_TIMEOUT, 0); + apr_socket_timeout_set(p_conn->sock, 0); socket_status = apr_recv(p_conn->sock, test_buffer, &buffer_len); /* put back old timeout */ - apr_setsocketopt(p_conn->sock, APR_SO_TIMEOUT, current_timeout); + apr_socket_timeout_set(p_conn->sock, current_timeout); if ( APR_STATUS_IS_EOF(socket_status) ) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "proxy: HTTP: previous connection is closed"); diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index ffb30255b9..3d0a4ffb90 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1158,10 +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_socket_timeout_set(*newsock, conf->timeout); } else { - apr_setsocketopt(*newsock, APR_SO_TIMEOUT, (int)s->timeout); + apr_socket_timeout_set(*newsock, s->timeout); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, diff --git a/server/connection.c b/server/connection.c index e84d88a8da..e960fc6c60 100644 --- a/server/connection.c +++ b/server/connection.c @@ -178,8 +178,8 @@ AP_DECLARE(void) ap_lingering_close(conn_rec *c) * not send us bytes within 2 seconds (a value pulled from Apache 1.3 * which seems to work well), close the connection. */ - timeout = SECONDS_TO_LINGER * APR_USEC_PER_SEC; - apr_setsocketopt(csd, APR_SO_TIMEOUT, timeout); + timeout = apr_time_from_sec(SECONDS_TO_LINGER); + apr_socket_timeout_set(csd, timeout); apr_setsocketopt(csd, APR_INCOMPLETE_READ, 1); while (1) { nbytes = sizeof(dummybuf); diff --git a/server/core.c b/server/core.c index 17c7b21bae..3b0603532a 100644 --- a/server/core.c +++ b/server/core.c @@ -2686,11 +2686,11 @@ static apr_status_t sendfile_it_all(core_net_rec *c, { apr_status_t rv; #ifdef AP_DEBUG - apr_int32_t timeout = 0; + apr_interval_time_t timeout = 0; #endif - AP_DEBUG_ASSERT((apr_getsocketopt(c->client_socket, APR_SO_TIMEOUT, - &timeout) == APR_SUCCESS) + AP_DEBUG_ASSERT((apr_socket_timeout_get(c->client_socket, &timeout) + == APR_SUCCESS) && timeout > 0); /* socket must be in timeout mode */ do { @@ -3308,16 +3308,15 @@ static int net_time_filter(ap_filter_t *f, apr_bucket_brigade *b, if (mode != AP_MODE_INIT && mode != AP_MODE_EATCRLF) { if (*first_line) { - apr_setsocketopt(csd, APR_SO_TIMEOUT, - (int)(keptalive - ? f->c->base_server->keep_alive_timeout - : f->c->base_server->timeout)); + apr_socket_timeout_set(csd, + keptalive + ? f->c->base_server->keep_alive_timeout + : f->c->base_server->timeout); *first_line = 0; } else { if (keptalive) { - apr_setsocketopt(csd, APR_SO_TIMEOUT, - (int)(f->c->base_server->timeout)); + apr_socket_timeout_set(csd, f->c->base_server->timeout); } } } diff --git a/server/mpm_common.c b/server/mpm_common.c index 2cd2c8e020..1ebca2de64 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -494,7 +494,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod) * because the MPM won't want to hold up a graceful restart for a * long time */ - rv = apr_setsocketopt(sock, APR_SO_TIMEOUT, 3 * APR_USEC_PER_SEC); + rv = apr_socket_timeout_set(sock, apr_time_from_sec(3)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "set timeout on socket to connect to listener"); diff --git a/server/rfc1413.c b/server/rfc1413.c index 5c11187b11..89c3edf494 100644 --- a/server/rfc1413.c +++ b/server/rfc1413.c @@ -147,10 +147,9 @@ static apr_status_t rfc1413_connect(apr_socket_t **newsock, conn_rec *conn, return rv; } - if ((rv = apr_setsocketopt(*newsock, APR_SO_TIMEOUT, - (apr_int32_t)(ap_rfc1413_timeout - * APR_USEC_PER_SEC))) - != APR_SUCCESS) { + if ((rv = apr_socket_timeout_set(*newsock, APR_SO_TIMEOUT, + apr_time_from_sec(ap_rfc1413_timeout))) + != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, srv, "rfc1413: error setting query socket timeout"); apr_socket_close(*newsock);