You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rj...@apache.org on 2011/09/08 12:18:14 UTC

svn commit: r1166606 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS modules/proxy/ajp.h modules/proxy/ajp_header.c modules/proxy/mod_proxy_ajp.c

Author: rjung
Date: Thu Sep  8 10:18:14 2011
New Revision: 1166606

URL: http://svn.apache.org/viewvc?rev=1166606&view=rev
Log:
mod_proxy_ajp: Respect "reuse" flag in
END_REPONSE packets.

Backport of r1152379 from trunk.

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/modules/proxy/ajp.h
    httpd/httpd/branches/2.2.x/modules/proxy/ajp_header.c
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=1166606&r1=1166605&r2=1166606&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Thu Sep  8 10:18:14 2011
@@ -19,6 +19,9 @@ Changes with Apache 2.2.21
      before returning the entire resource, with a default limit of 200.
      [Eric Covener]
 
+  *) mod_proxy_ajp: Respect "reuse" flag in END_REPONSE packets.
+     [Rainer Jung]
+
 Changes with Apache 2.2.20
 
   *) SECURITY: CVE-2011-3192 (cve.mitre.org)

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=1166606&r1=1166605&r2=1166606&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Thu Sep  8 10:18:14 2011
@@ -102,11 +102,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
                (Accept-Range: changeset in separate proposal below)
     +1: covener, wrowe, rpluem
 
-  * mod_proxy_ajp: Respect "reuse" flag in END_RESPONSE
-    Trunk patch: http://svn.apache.org/viewvc?rev=1152379&view=rev
-    2.2.x patch: http://people.apache.org/~rjung/patches/mod_proxy_ajp_reuse_flag.patch
-    +1: rjung, jim, jfclere
-
   * mod_proxy_ajp: Ignore flushing if headers have not been sent.
     Trunk patch: http://svn.apache.org/viewvc?rev=1153531&view=rev
     2.2.x patch: http://people.apache.org/~rpluem/patches/51608.diff

Modified: httpd/httpd/branches/2.2.x/modules/proxy/ajp.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/ajp.h?rev=1166606&r1=1166605&r2=1166606&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/ajp.h (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/ajp.h Thu Sep  8 10:18:14 2011
@@ -482,6 +482,17 @@ apr_status_t  ajp_parse_data(request_rec
                              apr_uint16_t *len, char **ptr);
 
 
+/**
+ * Check the reuse flag in CMD_AJP13_END_RESPONSE
+ * @param r         current request
+ * @param msg       AJP message
+ * @param reuse     returned reuse flag
+ * @return          APR_SUCCESS or error
+ */
+apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg,
+                             apr_byte_t *reuse);
+
+
 /** 
  * Handle the CPING/CPONG messages
  * @param sock      backend socket

Modified: httpd/httpd/branches/2.2.x/modules/proxy/ajp_header.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/ajp_header.c?rev=1166606&r1=1166605&r2=1166606&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/ajp_header.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/ajp_header.c Thu Sep  8 10:18:14 2011
@@ -714,7 +714,8 @@ apr_status_t ajp_parse_header(request_re
     }
     if (result != CMD_AJP13_SEND_HEADERS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
-               "ajp_parse_headers: wrong type %02x expecting 0x04", result);
+               "ajp_parse_headers: wrong type 0x%02x expecting 0x%02x",
+               result, CMD_AJP13_SEND_HEADERS);
         return AJP_EBAD_HEADER;
     }
     return ajp_unmarshal_response(msg, r, conf);
@@ -736,7 +737,8 @@ apr_status_t  ajp_parse_data(request_rec
     }
     if (result != CMD_AJP13_SEND_BODY_CHUNK) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
-               "ajp_parse_data: wrong type %02x expecting 0x03", result);
+               "ajp_parse_data: wrong type 0x%02x expecting 0x%02x",
+               result, CMD_AJP13_SEND_BODY_CHUNK);
         return AJP_EBAD_HEADER;
     }
     rc = ajp_msg_get_uint16(msg, len);
@@ -764,6 +766,28 @@ apr_status_t  ajp_parse_data(request_rec
     return APR_SUCCESS;
 }
 
+/* Check the reuse flag in CMD_AJP13_END_RESPONSE */
+apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg,
+                             apr_byte_t *reuse)
+{
+    apr_byte_t result;
+    apr_status_t rc;
+
+    rc = ajp_msg_get_uint8(msg, &result);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_parse_reuse: ajp_msg_get_byte failed");
+        return rc;
+    }
+    if (result != CMD_AJP13_END_RESPONSE) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_parse_reuse: wrong type 0x%02x expecting 0x%02x",
+               result, CMD_AJP13_END_RESPONSE);
+        return AJP_EBAD_HEADER;
+    }
+    return ajp_msg_get_uint8(msg, reuse);
+}
+
 /*
  * Allocate a msg to send data
  */

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c?rev=1166606&r1=1166605&r2=1166606&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c Thu Sep  8 10:18:14 2011
@@ -174,6 +174,7 @@ static int ap_proxy_ajp_request(apr_pool
     char *buff;
     char *send_body_chunk_buff;
     apr_uint16_t size;
+    apr_byte_t conn_reuse = 0;
     const char *tenc;
     int havebody = 1;
     int output_failed = 0;
@@ -485,6 +486,10 @@ static int ap_proxy_ajp_request(apr_pool
                 }
                 break;
             case CMD_AJP13_END_RESPONSE:
+                status = ajp_parse_reuse(r, conn->data, &conn_reuse);
+                if (status != APR_SUCCESS) {
+                    backend_failed = 1;
+                }
                 e = apr_bucket_eos_create(r->connection->bucket_alloc);
                 APR_BRIGADE_INSERT_TAIL(output_brigade, e);
                 if (ap_pass_brigade(r->output_filters,
@@ -564,6 +569,10 @@ static int ap_proxy_ajp_request(apr_pool
             rv = DONE;
         }
     }
+    else if (!conn_reuse) {
+        /* Our backend signalled connection close */
+        conn->close++;
+    }
     else {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                      "proxy: got response from %pI (%s)",