]> granicus.if.org Git - apache/commitdiff
Backport r1669299 from trunk:
authorEric Covener <covener@apache.org>
Wed, 15 Apr 2015 17:57:18 +0000 (17:57 +0000)
committerEric Covener <covener@apache.org>
Wed, 15 Apr 2015 17:57:18 +0000 (17:57 +0000)
  *) mod_proxy_wstunnel: Avoid an empty response by failing with 502 (Bad
     Gateway) when no response is ever received from the backend.

Submitted By: jkaluza
Reviewde By: covener, ylavic, trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1673902 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/proxy/mod_proxy_wstunnel.c

diff --git a/CHANGES b/CHANGES
index 1e81c1c0db034d1a5c42a34253ebd9fde711575d..6f3dac62df90050b88fae87ebceb67f13aae76a5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,10 @@ Changes with Apache 2.4.13
   *) mod_proxy: Add ap_connection_reusable() for checking if a connection
      is reusable as of this point in processing.  [Jeff Trawick]
 
+  *) mod_proxy_wstunnel: Avoid an empty response by failing with 502 (Bad
+     Gateway) when no response is ever received from the backend.
+     [Jan Kaluza]
+
   *) core_filters: restore/disable TCP_NOPUSH option after non-blocking
      sendfile.  [Yann Ylavic]
 
diff --git a/STATUS b/STATUS
index c1ce99fd2fb8f894fe9937a58f6bfdc92031ad7f..949e03ebf7184cb2a27aa55e7e5f8d41a8906ceb 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,12 +105,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_proxy_wstunnel: Avoid an empty response by failing with 502 (Bad
-     Gateway) when no response is ever received from the backend.
-     trunk patch: http://svn.apache.org/r1669299
-     2.4.x patch: http://people.apache.org/~covener/patches/httpd-2.4.x-wstunel-noreply.diff 
-     +1 covener, ylavic, trawick
-
   *) mod_ssl: Fix possible crash when loading server certificate constraints.
      PR 57694.
      trunk patch: http://svn.apache.org/r1666297
index 1dd7e658e975c3d4a846a54a910ac5813a76dd2e..fb72041bdf4d93d65ada816f28e7e64d617b3f20 100644 (file)
@@ -91,7 +91,7 @@ static int proxy_wstunnel_canon(request_rec *r, char *url)
 
 
 static apr_status_t proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
-                                     apr_bucket_brigade *bb, char *name)
+                                     apr_bucket_brigade *bb, char *name, int *sent)
 {
     apr_status_t rv;
 #ifdef DEBUGGING
@@ -116,6 +116,9 @@ static apr_status_t proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_
                           "read %" APR_OFF_T_FMT
                           " bytes from %s", len, name);
 #endif
+            if (sent) {
+                *sent = 1;
+            }
             rv = ap_pass_brigade(c_o->output_filters, bb);
             if (rv == APR_SUCCESS) {
                 ap_fflush(c_o->output_filters, bb);
@@ -167,7 +170,7 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
     char *old_te_val = NULL;
     apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
     apr_socket_t *client_socket = ap_get_conn_socket(c);
-    int done = 0;
+    int done = 0, replied = 0;
 
     header_brigade = apr_brigade_create(p, backconn->bucket_alloc);
 
@@ -246,7 +249,7 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
                                   "sock was readable");
                     done |= proxy_wstunnel_transfer(r, backconn, c, bb,
-                                                    "sock") != APR_SUCCESS;
+                                                    "sock", NULL) != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
@@ -266,7 +269,7 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
                                   "client was readable");
                     done |= proxy_wstunnel_transfer(r, c, backconn, bb,
-                                                    "client") != APR_SUCCESS;
+                                                    "client", &replied) != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
@@ -292,6 +295,13 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
     ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                   "finished with poll() - cleaning up");
 
+    if (!replied) {
+        return HTTP_BAD_GATEWAY;
+    }
+    else {
+        return OK;
+    }
+
     return OK;
 }