Attached is a patch to store timeout and keep_alive_timeout as apr_time_t
[whatever representation in use] as they are generally food for apr.  Only
two
conversions to seconds, one in creating the Keep-Alive header, and one
in mod_info are actually done at request time.  The burden of converting
to apr_time_t is moved to config-time.

I need a real +1 to proceed [e.g. grep for ->timeout
and ->keep_alive_timeout
and see that you agree I caught all the references.]  This aught to be
straightened
up before we experiment with binary usec representations of apr_time_t.

Bill

Index: include/httpd.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
retrieving revision 1.184
diff -u -r1.184 httpd.h
--- include/httpd.h     30 May 2002 07:04:45 -0000      1.184
+++ include/httpd.h     12 Jun 2002 16:40:29 -0000
@@ -1078,10 +1078,10 @@
 
     /** I haven't got a clue */
     server_addr_rec *addrs;
-    /** Timeout, in seconds, before we give up */
-    int timeout;
+    /** Timeout, in apr time, before we give up */
+    apr_time_t timeout;
     /** Seconds we'll wait for another request */
-    int keep_alive_timeout;
+    apr_time_t keep_alive_timeout;
     /** Maximum requests per connection */
     int keep_alive_max;
     /** Use persistent connections? */
Index: modules/experimental/mod_ext_filter.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_ext_filter.c,v
retrieving revision 1.28
diff -u -r1.28 mod_ext_filter.c
--- modules/experimental/mod_ext_filter.c       17 May 2002 11:33:09 -0000      1.28
+++ modules/experimental/mod_ext_filter.c       12 Jun 2002 16:40:30 -0000
@@ -604,7 +604,7 @@
                 
                 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 @@
          * 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: modules/generators/mod_cgi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
retrieving revision 1.141
diff -u -r1.141 mod_cgi.c
--- modules/generators/mod_cgi.c        6 Jun 2002 00:16:59 -0000       1.141
+++ modules/generators/mod_cgi.c        12 Jun 2002 16:40:30 -0000
@@ -490,23 +490,18 @@
             *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: modules/generators/mod_info.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_info.c,v
retrieving revision 1.47
diff -u -r1.47 mod_info.c
--- modules/generators/mod_info.c       7 May 2002 23:41:36 -0000       1.47
+++ modules/generators/mod_info.c       12 Jun 2002 16:40:30 -0000
@@ -393,9 +393,10 @@
                         "<tt>%s:%u</tt></dt>\n",
                         ap_get_server_name(r), ap_get_server_port(r));
             ap_rprintf(r, "<dt><strong>Timeouts:</strong> "
-                        "<tt>connection: %d &nbsp;&nbsp; "
-                        "keep-alive: %d</tt></dt>",
-                        serv->timeout, serv->keep_alive_timeout);
+                        "<tt>connection: %.2f &nbsp;&nbsp; "
+                        "keep-alive: %.2f</tt></dt>",
+                        (double)serv->timeout / APR_USEC_PER_SEC, 
+                        (double)serv->keep_alive_timeout / APR_USEC_PER_SEC);
             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: modules/http/http_core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
retrieving revision 1.302
diff -u -r1.302 http_core.c
--- modules/http/http_core.c    5 Apr 2002 20:55:00 -0000       1.302
+++ modules/http/http_core.c    12 Jun 2002 16:40:30 -0000
@@ -91,7 +91,7 @@
         return err;
     }
 
-    cmd->server->keep_alive_timeout = atoi(arg);
+    cmd->server->keep_alive_timeout = APR_TIME_FROM_SEC(atoi(arg));
     return NULL;
 }
 
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.434
diff -u -r1.434 http_protocol.c
--- modules/http/http_protocol.c        8 Jun 2002 04:36:05 -0000       1.434
+++ modules/http/http_protocol.c        12 Jun 2002 16:40:30 -0000
@@ -254,14 +254,14 @@
         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: modules/proxy/mod_proxy.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/mod_proxy.c,v
retrieving revision 1.84
diff -u -r1.84 mod_proxy.c
--- modules/proxy/mod_proxy.c   30 May 2002 07:33:59 -0000      1.84
+++ modules/proxy/mod_proxy.c   12 Jun 2002 16:40:30 -0000
@@ -886,7 +886,7 @@
         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: modules/proxy/proxy_ftp.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ftp.c,v
retrieving revision 1.120
diff -u -r1.120 proxy_ftp.c
--- modules/proxy/proxy_ftp.c   17 May 2002 11:24:16 -0000      1.120
+++ modules/proxy/proxy_ftp.c   12 Jun 2002 16:40:30 -0000
@@ -968,14 +968,11 @@
 
     /* 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: modules/proxy/proxy_util.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_util.c,v
retrieving revision 1.91
diff -u -r1.91 proxy_util.c
--- modules/proxy/proxy_util.c  17 May 2002 11:24:16 -0000      1.91
+++ modules/proxy/proxy_util.c  12 Jun 2002 16:40:30 -0000
@@ -1158,12 +1158,10 @@
 
         /* 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: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.182
diff -u -r1.182 core.c
--- server/core.c       31 May 2002 20:52:28 -0000      1.182
+++ server/core.c       12 Jun 2002 16:40:30 -0000
@@ -2041,7 +2041,7 @@
         return err;
     }
 
-    cmd->server->timeout = atoi(arg);
+    cmd->server->timeout = APR_TIME_FROM_SEC(atoi(arg));
     return NULL;
 }
 
@@ -3310,14 +3310,14 @@
         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));
             }
         }
     }

Reply via email to