]> granicus.if.org Git - apache/commitdiff
Solve the 80/20 by initializing and storing server_rec->timeout and
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 12 Jun 2002 23:59:31 +0000 (23:59 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 12 Jun 2002 23:59:31 +0000 (23:59 +0000)
  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

12 files changed:
include/ap_mmn.h
include/httpd.h
modules/experimental/mod_ext_filter.c
modules/generators/mod_cgi.c
modules/generators/mod_info.c
modules/http/http_core.c
modules/http/http_protocol.c
modules/proxy/mod_proxy.c
modules/proxy/proxy_ftp.c
modules/proxy/proxy_util.c
server/config.c
server/core.c

index 92454800484eae4904055c5918b6bba435b867ee..13938579b1675543aae64b5274ab579bfce62d13 100644 (file)
  * 20020506 (2.0.37-dev) Removed r->boundary in request_rec.
  * 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs
  * 20020602 (2.0.37-dev) Bucket API change (metadata buckets)
+ * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20020602
+#define MODULE_MAGIC_NUMBER_MAJOR 20020612
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
index 78cdb4121aba788aec5c59650235809ddc616c33..e70044cba6093882a0cf2d573ff149d8f33076b4 100644 (file)
@@ -1078,10 +1078,10 @@ struct server_rec {
 
     /** I haven't got a clue */
     server_addr_rec *addrs;
-    /** Timeout, in seconds, before we give up */
-    int timeout;
-    /** Seconds we'll wait for another request */
-    int keep_alive_timeout;
+    /** Timeout, as an apr interval, before we give up */
+    apr_interval_time_t timeout;
+    /** The apr interval we will wait for another request */
+    apr_interval_time_t keep_alive_timeout;
     /** Maximum requests per connection */
     int keep_alive_max;
     /** Use persistent connections? */
index e7ddee2cbe7f5992b0179acd4b633a2efc4a00b1..8e944086038ebc31bf4ec7a7d282ad2b1ab0b4c1 100644 (file)
@@ -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)");
index 88e70ae20786a099f38be72a664c552975ef1d06..daad028808def72829adc5d1df13880c527fd895 100644 (file)
@@ -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);
             }
         }
     }
index 3623155f72cdae745975e74718701d0c395b1635..f29b82f6f804f839e68031925119128f08680410 100644 (file)
@@ -395,7 +395,8 @@ static int display_info(request_rec *r)
             ap_rprintf(r, "<dt><strong>Timeouts:</strong> "
                         "<tt>connection: %d &nbsp;&nbsp; "
                         "keep-alive: %d</tt></dt>",
-                        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);
index 854b7c9289341351ba56e0411173e8813c6c6c51..cc51aee6446ba62bd5ae6ff1b6526f23c1015384 100644 (file)
@@ -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;
 }
 
index cab3bafe0c400d0b9384ae5c14ce18f3b815d55b..7a1f4e8e7aedededa7a44ee2521265d47446b0b0 100644 (file)
@@ -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");
         }
index 513c82045c4508041699ac23d6ee436d7dad4e2d..e78415aae341127e7003a401e94890a73dfeaa83 100644 (file)
@@ -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;    
 }
index 93b5582fe2196b25ea0c74f24fe6c277fde413b2..4bbcaf679e8474603a39c7cecd4460ab35d6a734 100644 (file)
@@ -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,
index 355e51bad8a5857a38de26e555b3f658bb3d8327..94106f8c9c3571506fe42fa51506ebd311cc627c 100644 (file)
@@ -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,
index 0b0ded380a92c1bc11b16dd28036cd8ead2c30a0..d8932345da8ccbdf2f95a079aaa8825408a98d0a 100644 (file)
@@ -1726,8 +1726,8 @@ static server_rec *init_server_config(process_rec *process, apr_pool_t *p)
     s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
     s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
     s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
-    s->timeout = DEFAULT_TIMEOUT;
-    s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
+    s->timeout = apr_time_from_sec(DEFAULT_TIMEOUT);
+    s->keep_alive_timeout = apr_time_from_sec(DEFAULT_KEEPALIVE_TIMEOUT);
     s->keep_alive_max = DEFAULT_KEEPALIVE;
     s->keep_alive = 1;
     s->next = NULL;
index 8454dbc9978c061ec5e29c3e8856c363d8028357..037454b0dcdbd754b49ee143ca7bd482463cdd4e 100644 (file)
@@ -2041,7 +2041,7 @@ static const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
         return err;
     }
 
-    cmd->server->timeout = atoi(arg);
+    cmd->server->timeout = apr_time_from_sec(atoi(arg));
     return NULL;
 }
 
@@ -3310,14 +3310,14 @@ static int net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
         if (*first_line) {
             apr_setsocketopt(csd, APR_SO_TIMEOUT,
                              (int)(keptalive
-                      ? f->c->base_server->keep_alive_timeout * APR_USEC_PER_SEC
-                      : f->c->base_server->timeout * APR_USEC_PER_SEC));
+                      ? 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_USEC_PER_SEC));
+                                 (int)(f->c->base_server->timeout));
             }
         }
     }