]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_ajp: Respect "reuse" flag in END_REPONSE
authorRainer Jung <rjung@apache.org>
Fri, 29 Jul 2011 21:41:00 +0000 (21:41 +0000)
committerRainer Jung <rjung@apache.org>
Fri, 29 Jul 2011 21:41:00 +0000 (21:41 +0000)
packets.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1152379 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/ajp.h
modules/proxy/ajp_header.c
modules/proxy/mod_proxy_ajp.c

diff --git a/CHANGES b/CHANGES
index 371d18d0571da3c47b556ff8b0fd7638388fa6df..b0bff8759513bf4a62a2566835665bb86e36a6de 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.14
 
+  *) mod_proxy_ajp: Respect "reuse" flag in END_REPONSE packets.
+     [Rainer Jung]
+
   *) mod_proxy: enable absolute URLs to be rewritten with ProxyPassReverse,
      e.g. to reverse proxy "Location: https://other-internal-server/login"
      [Nick Kew]
index 0674cde5b96a76532ee9b35de42007876452c30d..ae64f817cf4176eabf42c9d3ac1088e3627c4497 100644 (file)
@@ -470,6 +470,17 @@ apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
                              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
index 485708f7fbfee2412080550789f3c9641d14214c..137c7fa225b684c88b8630de1f009a1f79ce5b0e 100644 (file)
@@ -712,7 +712,8 @@ apr_status_t ajp_parse_header(request_rec  *r, proxy_dir_conf *conf,
     }
     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);
@@ -734,7 +735,8 @@ apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
     }
     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);
@@ -762,6 +764,28 @@ apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
     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
  */
index 7b44fcbe34b170f0c9e807fea967c43991b67853..bf435f6b22cedf7b422aa86af50c95567c58f790 100644 (file)
@@ -174,6 +174,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     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;
@@ -527,6 +528,10 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                  * the client, especially as the brigade already contains headers.
                  * So do nothing here, and it will be cleaned up below.
                  */
+                status = ajp_parse_reuse(r, conn->data, &conn_reuse);
+                if (status != APR_SUCCESS) {
+                    backend_failed = 1;
+                }
                 if (!conf->error_override || !ap_is_HTTP_ERROR(r->status)) {
                     e = apr_bucket_eos_create(r->connection->bucket_alloc);
                     APR_BRIGADE_INSERT_TAIL(output_brigade, e);
@@ -608,6 +613,10 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
             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)",