httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r553593 - in /httpd/httpd/branches/2.2.x: STATUS modules/proxy/mod_proxy_ajp.c
Date Thu, 05 Jul 2007 18:19:33 GMT
Author: jim
Date: Thu Jul  5 11:19:32 2007
New Revision: 553593

URL: http://svn.apache.org/viewvc?view=rev&rev=553593
Log:
Real fix for 40310

Modified:
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?view=diff&rev=553593&r1=553592&r2=553593
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Thu Jul  5 11:19:32 2007
@@ -77,20 +77,6 @@
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_proxy_ajp: Fix wrong retry when sending the response failed.
-      PR 40310 (The old fixes weren't ok).
-      Trunk version of patch:
-        http://svn.apache.org/viewvc?view=rev&revision=518938
-        http://svn.apache.org/viewvc?view=rev&revision=534031
-      2.2.x version of patch:
-        http://people.apache.org/~rpluem/patches/40310.diff
-      +1: rpluem, jfclere, jim
-      jerenkrantz says: Does not apply cleanly to 2.2.x.
-      rpluem answers: svn merge did not notice this / resolved this, but you are
-                      correct. There is a conflict because r467014 is not
-                      backported to 2.2.x so far. So I reset the votes and add a
-                      version of the patch that applies cleanly to 2.2.x.
-
     * mod_cache: Correctly handle HEAD requests on expired cache content.
       PR 41230
       Trunk version of patch:

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?view=diff&rev=553593&r1=553592&r2=553593
==============================================================================
--- 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 Jul  5 11:19:32 2007
@@ -127,7 +127,8 @@
     apr_uint16_t size;
     const char *tenc;
     int havebody = 1;
-    int isok = 1;
+    int output_failed = 0;
+    int backend_failed = 0;
     apr_off_t bb_len;
     int data_sent = 0;
     int rv = 0;
@@ -252,7 +253,7 @@
     conn_poll->desc.s = conn->sock;
 
     bufsiz = AJP13_MAX_SEND_BODY_SZ;
-    while (isok) {
+    for (;;) {
         switch (result) {
             case CMD_AJP13_GET_BODY_CHUNK:
                 if (havebody) {
@@ -271,6 +272,7 @@
                             ap_log_error(APLOG_MARK, APLOG_DEBUG, status,
                                          r->server,
                                          "ap_get_brigade failed");
+                            output_failed = 1;
                             break;
                         }
                         bufsiz = AJP13_MAX_SEND_BODY_SZ;
@@ -281,6 +283,7 @@
                             ap_log_error(APLOG_MARK, APLOG_DEBUG, status,
                                          r->server,
                                          "apr_brigade_flatten failed");
+                            output_failed = 1;
                             break;
                         }
                     }
@@ -291,6 +294,7 @@
                     if (status != APR_SUCCESS) {
                         ap_log_error(APLOG_MARK, APLOG_DEBUG, status, r->server,
                                      "ajp_send_data_msg failed");
+                        backend_failed = 1;
                         break;
                     }
                     conn->worker->s->transferred += bufsiz;
@@ -301,14 +305,14 @@
                      */
                     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                                  "ap_proxy_ajp_request error read after end");
-                    isok = 0;
+                    backend_failed = 1;
                 }
                 break;
             case CMD_AJP13_SEND_HEADERS:
                 /* AJP13_SEND_HEADERS: process them */
                 status = ajp_parse_header(r, conf, conn->data);
                 if (status != APR_SUCCESS) {
-                    isok = 0;
+                    backend_failed = 1;
                 }
                 break;
             case CMD_AJP13_SEND_BODY_CHUNK:
@@ -343,13 +347,13 @@
                                         output_brigade) != APR_SUCCESS) {
                         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                                       "proxy: error processing body");
-                        isok = 0;
+                        output_failed = 1;
                     }
                     data_sent = 1;
                     apr_brigade_cleanup(output_brigade);
                 }
                 else {
-                    isok = 0;
+                    backend_failed = 1;
                 }
                 break;
             case CMD_AJP13_END_RESPONSE:
@@ -358,40 +362,42 @@
                 if (ap_pass_brigade(r->output_filters,
                                     output_brigade) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                                  "proxy: error processing body");
-                    isok = 0;
+                                  "proxy: error processing end");
+                    output_failed = 1;
                 }
                 /* XXX: what about flush here? See mod_jk */
                 data_sent = 1;
                 break;
             default:
-                isok = 0;
+                backend_failed = 1;
                 break;
         }
 
         /*
          * If connection has been aborted by client: Stop working.
          * Nevertheless, we regard our operation so far as a success:
-         * So do not set isok to 0 and set result to CMD_AJP13_END_RESPONSE
+         * So reset output_failed to 0 and set result to CMD_AJP13_END_RESPONSE
          * But: Close this connection to the backend.
          */
         if (r->connection->aborted) {
             conn->close++;
+            output_failed = 0;
             result = CMD_AJP13_END_RESPONSE;
-            break;
         }
 
-        if (!isok)
-            break;
-
-        if (result == CMD_AJP13_END_RESPONSE)
+        /*
+         * We either have finished successfully or we failed.
+         * So bail out
+         */
+        if ((result == CMD_AJP13_END_RESPONSE) || backend_failed
+            || output_failed)
             break;
 
         /* read the response */
         status = ajp_read_header(conn->sock, r,
                                  (ajp_msg_t **)&(conn->data));
         if (status != APR_SUCCESS) {
-            isok = 0;
+            backend_failed = 1;
             ap_log_error(APLOG_MARK, APLOG_DEBUG, status, r->server,
                          "ajp_read_header failed");
             break;
@@ -406,11 +412,28 @@
      */
     apr_brigade_cleanup(output_brigade);
 
-    if (status != APR_SUCCESS) {
+    if (backend_failed || output_failed) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "proxy: Processing of request failed backend: %i, "
+                     "output: %i", backend_failed, output_failed);
         /* We had a failure: Close connection to backend */
         conn->close++;
+        /* Return DONE to avoid error messages being added to the stream */
+        if (data_sent) {
+            rv = DONE;
+        }
+    }
+    else {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "proxy: got response from %pI (%s)",
+                     conn->worker->cp->addr,
+                     conn->worker->hostname);
+        rv = OK;
+    }
+
+    if (backend_failed) {
         ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
-                     "proxy: send body failed to %pI (%s)",
+                     "proxy: dialog to %pI (%s) failed",
                      conn->worker->cp->addr,
                      conn->worker->hostname);
         /*
@@ -419,8 +442,6 @@
          */
         if (data_sent) {
             ap_proxy_backend_broke(r, output_brigade);
-            /* Return DONE to avoid error messages being added to the stream */
-            rv = DONE;
         } else
             rv = HTTP_SERVICE_UNAVAILABLE;
     }
@@ -442,27 +463,7 @@
 
     apr_brigade_destroy(output_brigade);
 
-    if (rv)
-        return rv;
-
-    /* Nice we have answer to send to the client */
-    if (result == CMD_AJP13_END_RESPONSE && isok) {
-        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "proxy: got response from %pI (%s)",
-                     conn->worker->cp->addr,
-                     conn->worker->hostname);
-        return OK;
-    }
-
-    ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
-                 "proxy: got bad response (%d) from %pI (%s)",
-                 result,
-                 conn->worker->cp->addr,
-                 conn->worker->hostname);
-
-    /* We had a failure: Close connection to backend */
-    conn->close++;
-    return HTTP_SERVICE_UNAVAILABLE;
+    return rv;
 }
 
 /*



Mime
View raw message