]> granicus.if.org Git - apache/commitdiff
* mod_proxy_ajp: Fix client connection errors handling and logged status
authorYann Ylavic <ylavic@apache.org>
Sat, 6 Dec 2014 14:33:52 +0000 (14:33 +0000)
committerYann Ylavic <ylavic@apache.org>
Sat, 6 Dec 2014 14:33:52 +0000 (14:33 +0000)
when it occurs.  PR 56823.

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

CHANGES
docs/log-message-tags/next-number
modules/proxy/mod_proxy_ajp.c

diff --git a/CHANGES b/CHANGES
index b7338acfd10fe432cfd52c49d8115c0037dd6c3b..5aa969049c0d1d4df33987c0b4e4cef216349782 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
   
+  *) mod_proxy_ajp: Fix client connection errors handling and logged status
+     when it occurs.  PR 56823.  [Yann Ylavic]
+
   *) ap_expr: Add filemod function for checking file modification dates
      [Daniel Gruno]
      
index c5efbfab6446045a36b555d238a61deb36bb373c..9c1f8fc60e5c0bf715ac0eae25cf198c43fde087 100644 (file)
@@ -1 +1 @@
-2821
+2823
index 14035f33e22e24e936774390f589c1baa4478993..37afcc78c88c6353a6de3530519438806957b4e6 100644 (file)
@@ -186,7 +186,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     int data_sent = 0;
     int request_ended = 0;
     int headers_sent = 0;
-    int rv = 0;
+    int rv = OK;
     apr_int32_t conn_poll_fd;
     apr_pollfd_t *conn_poll;
     proxy_server_conf *psf =
@@ -394,6 +394,9 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                         if (status != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(00880)
                                           "ap_get_brigade failed");
+                            if (APR_STATUS_IS_TIMEUP(status)) {
+                                rv = HTTP_REQUEST_TIME_OUT;
+                            }
                             output_failed = 1;
                             break;
                         }
@@ -404,6 +407,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                         if (status != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(00881)
                                          "apr_brigade_flatten failed");
+                            rv = HTTP_INTERNAL_SERVER_ERROR;
                             output_failed = 1;
                             break;
                         }
@@ -559,15 +563,19 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
 
         /*
          * If connection has been aborted by client: Stop working.
-         * Nevertheless, we regard our operation so far as a success:
-         * So reset output_failed to 0 and set result to CMD_AJP13_END_RESPONSE
-         * But: Close this connection to the backend.
+         * Pretend we are done (data_sent) to avoid further processing.
          */
         if (r->connection->aborted) {
-            conn->close = 1;
-            output_failed = 0;
-            result = CMD_AJP13_END_RESPONSE;
-            request_ended = 1;
+            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02821)
+                          "client connection aborted");
+            /* no response yet (or ever), set status for access log */
+            if (!headers_sent) {
+                r->status = HTTP_BAD_REQUEST;
+            }
+            /* return DONE */
+            output_failed = 1;
+            data_sent = 1;
+            break;
         }
 
         /*
@@ -677,6 +685,14 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
             }
         }
     }
+    else if (output_failed) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02822)
+                      "dialog with client %pI failed",
+                      r->connection->client_addr);
+        if (rv == OK) {
+            rv = HTTP_BAD_REQUEST;
+        }
+    }
 
     /*
      * Ensure that we sent an EOS bucket thru the filter chain, if we already
@@ -684,7 +700,8 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
      * one to the brigade already (no longer making it empty). So we should
      * not do this in this case.
      */
-    if (data_sent && !r->eos_sent && APR_BRIGADE_EMPTY(output_brigade)) {
+    if (data_sent && !r->eos_sent && !r->connection->aborted
+            && APR_BRIGADE_EMPTY(output_brigade)) {
         e = apr_bucket_eos_create(r->connection->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(output_brigade, e);
     }