You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2004/08/28 01:44:42 UTC

cvs commit: apache-1.3/src/main http_protocol.c http_request.c

jim         2004/08/27 16:44:42

  Modified:    src      CHANGES
               src/main http_protocol.c http_request.c
  Log:
  Make ap_set_keepalive more statefully aware, allowing it
  to be called multiple times (to correctly set keepalive)
  but not increment keepalives when not needed. This allows
  us to handle a special case where we need to discard
  body content "early"
  
  Revision  Changes    Path
  1.1949    +3 -2      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1948
  retrieving revision 1.1949
  diff -u -r1.1948 -r1.1949
  --- CHANGES	27 Aug 2004 19:29:57 -0000	1.1948
  +++ CHANGES	27 Aug 2004 23:44:41 -0000	1.1949
  @@ -24,9 +24,10 @@
        was not checked properly. This affects mod_usertrack and
        core. PR 28218.  [Andr� Malo]
   
  -  *) No longer breaks mod_dav, frontpage and others.  Backs out
  -     a patch which prevented discarding the request body for requests
  +  *) No longer breaks mod_dav, frontpage and others.  Repair a patch
  +     in 1.3.31 which prevented discarding the request body for requests
        that will be keptalive but are not currently keptalive. PR 29237.
  +     [Jim Jagielski]
   
     *) COMPATIBILITY: Added new compile-time flag: UCN_OFF_HONOR_PHYSICAL_PORT.
        It controls how UseCanonicalName Off determines the port value if
  
  
  
  1.336     +12 -1     apache-1.3/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
  retrieving revision 1.335
  retrieving revision 1.336
  diff -u -r1.335 -r1.336
  --- http_protocol.c	15 Apr 2004 15:51:51 -0000	1.335
  +++ http_protocol.c	27 Aug 2004 23:44:41 -0000	1.336
  @@ -391,6 +391,7 @@
       int wimpy = ap_find_token(r->pool,
                              ap_table_get(r->headers_out, "Connection"), "close");
       const char *conn = ap_table_get(r->headers_in, "Connection");
  +    const char *herebefore = ap_table_get(r->notes, "ap_set_keepalive-called");
   
       /* The following convoluted conditional determines whether or not
        * the current connection should remain persistent after this response
  @@ -442,7 +443,17 @@
           int left = r->server->keep_alive_max - r->connection->keepalives;
   
           r->connection->keepalive = 1;
  -        r->connection->keepalives++;
  +	/*
  +	 * ap_set_keepalive could be called multiple times (eg: in
  +	 * ap_die() followed by ap_send_http_header()) during this
  +	 * one single request. To ensure that we don't incorrectly
  +	 * increment the keepalives counter for each call, we
  +	 * use notes to store a state flag.
  +	 */
  +	if (!herebefore) {
  +            r->connection->keepalives++;
  +            ap_table_setn(r->notes, "ap_set_keepalive-called", "1");
  +	}
   
           /* If they sent a Keep-Alive token, send one back */
           if (ka_sent) {
  
  
  
  1.176     +7 -1      apache-1.3/src/main/http_request.c
  
  Index: http_request.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_request.c,v
  retrieving revision 1.175
  retrieving revision 1.176
  diff -u -r1.175 -r1.176
  --- http_request.c	28 May 2004 12:07:02 -0000	1.175
  +++ http_request.c	27 Aug 2004 23:44:41 -0000	1.176
  @@ -1051,12 +1051,18 @@
       }
   
       /*
  +     * We need to ensure that r->connection->keepalive is valid in
  +     * order to determine if we can discard the request body below.
  +     */
  +    ap_set_keepalive(r);
  +
  +    /*
        * If we want to keep the connection, be sure that the request body
        * (if any) has been read.
        */
       if ((r->status != HTTP_NOT_MODIFIED) && (r->status != HTTP_NO_CONTENT)
           && !ap_status_drops_connection(r->status)
  -        && r->connection && (r->connection->keepalive != -1)) {
  +        && r->connection && (r->connection->keepalive > 0)) {
   
           (void) ap_discard_request_body(r);
       }