httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Erenkrantz <jerenkra...@apache.org>
Subject [PATCH] Change keepalive to an enum
Date Wed, 26 Jun 2002 05:04:43 GMT
Since my naming skills aren't that good, I'd like some people to
review this name change before committing.  I also haven't tested
it yet, but I don't expect any problems.

I believe that this requires a MMN bump since we're chaning a core
structure around.  There are some more fields that are still
bitfields - I imagine that we could change those also before the
next release.

This will also fix the mod_dav/EOS/400 problem that Karl reported
earlier.  -- justin

Index: include/ap_mmn.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/ap_mmn.h,v
retrieving revision 1.49
diff -u -r1.49 ap_mmn.h
--- include/ap_mmn.h	12 Jun 2002 23:59:29 -0000	1.49
+++ include/ap_mmn.h	26 Jun 2002 04:58:19 -0000
@@ -108,14 +108,15 @@
  * 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
+ * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20020612
+#define MODULE_MAGIC_NUMBER_MAJOR 20020625
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Index: include/httpd.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
retrieving revision 1.187
diff -u -r1.187 httpd.h
--- include/httpd.h	23 Jun 2002 09:01:22 -0000	1.187
+++ include/httpd.h	26 Jun 2002 04:58:21 -0000
@@ -951,6 +951,11 @@
 
 /* @} */
 
+typedef enum {
+    AP_CONN_UNKNOWN,
+    AP_CONN_CLOSE,
+    AP_CONN_KEEPALIVE
+} ap_conn_keepalive_e;
 
 /** Structure to store things which are per connection */
 struct conn_rec {
@@ -981,8 +986,8 @@
     unsigned aborted:1;
 
     /** Are we going to keep the connection alive for another request?
-     *  -1 fatal error, 0 undecided, 1 yes   */
-    signed int keepalive:2;
+     * @see ap_conn_keepalive_e */
+    ap_conn_keepalive_e keepalive;
 
     /** have we done double-reverse DNS? -1 yes/failure, 0 not yet, 
      *  1 yes/success */
Index: modules/arch/win32/mod_isapi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/arch/win32/mod_isapi.c,v
retrieving revision 1.81
diff -u -r1.81 mod_isapi.c
--- modules/arch/win32/mod_isapi.c	12 Jun 2002 22:27:37 -0000	1.81
+++ modules/arch/win32/mod_isapi.c	26 Jun 2002 04:58:24 -0000
@@ -1093,7 +1093,7 @@
         return 0;
 
     case HSE_REQ_IS_KEEP_CONN:
-        *((int *)buf_data) = (r->connection->keepalive == 1);
+        *((int *)buf_data) = (r->connection->keepalive == AP_CONN_KEEPALIVE);
         return 1;
 
     case HSE_REQ_ASYNC_READ_CLIENT:
Index: modules/http/http_core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
retrieving revision 1.303
diff -u -r1.303 http_core.c
--- modules/http/http_core.c	12 Jun 2002 23:59:30 -0000	1.303
+++ modules/http/http_core.c	26 Jun 2002 04:58:25 -0000
@@ -283,7 +283,7 @@
     ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL);
     while ((r = ap_read_request(c)) != NULL) {
  
-        c->keepalive = 0;
+        c->keepalive = AP_CONN_UNKNOWN;
         /* process the request if it was read without error */
  
         ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
@@ -293,7 +293,7 @@
         if (ap_extended_status)
             ap_increment_counts(c->sbh, r);
  
-        if (!c->keepalive || c->aborted)
+        if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted)
             break;
  
         ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, r);
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.441
diff -u -r1.441 http_protocol.c
--- modules/http/http_protocol.c	24 Jun 2002 17:06:19 -0000	1.441
+++ modules/http/http_protocol.c	26 Jun 2002 04:58:29 -0000
@@ -223,7 +223,7 @@
      *
      * Note that the condition evaluation order is extremely important.
      */
-    if ((r->connection->keepalive != -1)
+    if ((r->connection->keepalive != AP_CONN_CLOSE)
         && ((r->status == HTTP_NOT_MODIFIED)
             || (r->status == HTTP_NO_CONTENT)
             || r->header_only
@@ -247,7 +247,7 @@
             || (r->proto_num >= HTTP_VERSION(1,1)))) {
         int left = r->server->keep_alive_max - r->connection->keepalives;
 
-        r->connection->keepalive = 1;
+        r->connection->keepalive = AP_CONN_KEEPALIVE;
         r->connection->keepalives++;
 
         /* If they sent a Keep-Alive token, send one back */
@@ -281,7 +281,7 @@
         apr_table_mergen(r->headers_out, "Connection", "close");
     }
 
-    r->connection->keepalive = 0;
+    r->connection->keepalive = AP_CONN_CLOSE;
 
     return 0;
 }
@@ -1162,7 +1162,7 @@
     if (r->proto_num == HTTP_VERSION(1,0)
         && apr_table_get(r->subprocess_env, "force-response-1.0")) {
         *protocol = "HTTP/1.0";
-        r->connection->keepalive = -1;
+        r->connection->keepalive = AP_CONN_CLOSE;
     }
     else {
         *protocol = AP_SERVER_PROTOCOL;
@@ -1835,7 +1835,7 @@
         /* if we actually fail here, we want to just return and
          * stop trying to read data from the client.
          */
-        r->connection->keepalive = -1;
+        r->connection->keepalive = AP_CONN_CLOSE;
         return -1;
     }
 
@@ -1882,8 +1882,8 @@
      *
      * This function is also a no-op on a subrequest.
      */
-    if (r->main || !r->connection->keepalive
-                || ap_status_drops_connection(r->status)) {
+    if (r->main || r->connection->keepalive == AP_CONN_CLOSE ||
+        ap_status_drops_connection(r->status)) {
         return OK;
     }
 
Index: modules/http/http_request.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_request.c,v
retrieving revision 1.149
diff -u -r1.149 http_request.c
--- modules/http/http_request.c	21 Jun 2002 13:58:39 -0000	1.149
+++ modules/http/http_request.c	26 Jun 2002 04:58:30 -0000
@@ -143,7 +143,7 @@
      * connection, be sure that the request body (if any) has been read.
      */
     if (ap_status_drops_connection(r->status)) {
-        r->connection->keepalive = 0;
+        r->connection->keepalive = AP_CONN_CLOSE;
     }
 
     /*
@@ -216,7 +216,7 @@
      */
     /* ### shouldn't this read from the connection input filters? */
     /* ### is zero correct? that means "read one line" */
-    if (!r->connection->keepalive || 
+    if (r->connection->keepalive == AP_CONN_CLOSE || 
         ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF, 
                        APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
         apr_bucket *e = apr_bucket_flush_create(c->bucket_alloc);
Index: modules/loggers/mod_log_config.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/loggers/mod_log_config.c,v
retrieving revision 1.84
diff -u -r1.84 mod_log_config.c
--- modules/loggers/mod_log_config.c	9 Jun 2002 04:48:41 -0000	1.84
+++ modules/loggers/mod_log_config.c	26 Jun 2002 04:58:32 -0000
@@ -585,7 +585,7 @@
     if (r->connection->aborted)
         return "X";
 
-    if (r->connection->keepalive && 
+    if (r->connection->keepalive == AP_CONN_KEEPALIVE && 
         (!r->server->keep_alive_max ||
          (r->server->keep_alive_max - r->connection->keepalives) > 0)) {
         return "+";
Index: modules/proxy/proxy_http.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
retrieving revision 1.154
diff -u -r1.154 proxy_http.c
--- modules/proxy/proxy_http.c	23 Jun 2002 06:06:25 -0000	1.154
+++ modules/proxy/proxy_http.c	26 Jun 2002 04:58:34 -0000
@@ -446,7 +446,7 @@
     ap_proxy_clear_connection(p, r->headers_in);
     if (p_conn->close) {
         apr_table_setn(r->headers_in, "Connection", "close");
-        origin->keepalive = 0;
+        origin->keepalive = AP_CONN_CLOSE;
     }
 
     if ( apr_table_get(r->subprocess_env,"force-proxy-request-1.0")) {
@@ -456,7 +456,7 @@
     }
     if ( apr_table_get(r->subprocess_env,"proxy-nokeepalive")) {
         apr_table_unset(r->headers_in, "Connection");
-        origin->keepalive = 0;
+        origin->keepalive = AP_CONN_CLOSE;
     }
     ap_xlate_proto_to_ascii(buf, strlen(buf));
     e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
@@ -798,7 +798,7 @@
             /* cancel keepalive if HTTP/1.0 or less */
             if ((major < 1) || (minor < 1)) {
                 p_conn->close += 1;
-                origin->keepalive = 0;
+                origin->keepalive = AP_CONN_CLOSE;
             }
         } else {
             /* an http/0.9 response */
Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.184
diff -u -r1.184 core.c
--- server/core.c	15 Jun 2002 05:49:06 -0000	1.184
+++ server/core.c	26 Jun 2002 04:58:41 -0000
@@ -3293,7 +3293,7 @@
                            ap_input_mode_t mode, apr_read_type_e block,
                            apr_off_t readbytes)
 {
-    int keptalive = f->c->keepalive == 1;
+    int keptalive = f->c->keepalive == AP_CONN_KEEPALIVE;
     apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
     int *first_line = f->ctx;
 
@@ -3755,7 +3755,8 @@
              && (nbytes + flen < AP_MIN_BYTES_TO_WRITE)
              && !APR_BUCKET_IS_FLUSH(last_e))
             || (nbytes + flen < AP_MIN_BYTES_TO_WRITE 
-                && APR_BUCKET_IS_EOS(last_e) && c->keepalive)) {
+                && APR_BUCKET_IS_EOS(last_e)
+                && c->keepalive == AP_CONN_KEEPALIVE)) {
 
             /* NEVER save an EOS in here.  If we are saving a brigade with
              * an EOS bucket, then we are doing keepalive connections, and
@@ -3824,7 +3825,7 @@
             }
 
 #if APR_HAS_SENDFILE
-            if (!c->keepalive && APR_BUCKET_IS_EOS(last_e)) {
+            if (c->keepalive == AP_CONN_CLOSE && APR_BUCKET_IS_EOS(last_e)) {
                 /* Prepare the socket to be reused */
                 flags |= APR_SENDFILE_DISCONNECT_SOCKET;
             }
Index: server/protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
retrieving revision 1.106
diff -u -r1.106 protocol.c
--- server/protocol.c	10 Jun 2002 18:51:38 -0000	1.106
+++ server/protocol.c	26 Jun 2002 04:58:43 -0000
@@ -1046,8 +1046,6 @@
  */
 AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r)
 {
-    (void) ap_discard_request_body(r);
-
     while (r->next) {
         r = r->next;
     }
@@ -1056,6 +1054,12 @@
     if (!r->eos_sent) {
         end_output_stream(r);
     }
+
+    /* Discard the body after we have ended our output stream.
+     * This allows the ap_http_header_filter to set the keepalive
+     * status of the request.
+     */
+    (void) ap_discard_request_body(r);
 }
 
 /*
@@ -1187,7 +1191,8 @@
      * We should be able to force connection close from this filter
      * when we see we are buffering too much.
      */
-    if ((r->proto_num >= HTTP_VERSION(1, 1)) || (!r->connection->keepalive))
{
+    if ((r->proto_num >= HTTP_VERSION(1, 1)) ||
+        (r->connection->keepalive == AP_CONN_CLOSE)) {
         partial_send_okay = 1;
     }
 

Mime
View raw message