Blame SOURCES/httpd-2.4.6-r1587053.patch

008793
diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c
008793
index 525109a..eb34eee 100644
008793
--- a/modules/proxy/mod_proxy_wstunnel.c
008793
+++ b/modules/proxy/mod_proxy_wstunnel.c
008793
@@ -103,10 +103,12 @@ static int proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
008793
         rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
008793
                             APR_NONBLOCK_READ, AP_IOBUFSIZE);
008793
         if (rv == APR_SUCCESS) {
008793
-            if (c_o->aborted)
008793
+            if (c_o->aborted) {
008793
                 return APR_EPIPE;
008793
-            if (APR_BRIGADE_EMPTY(bb))
008793
+            }
008793
+            if (APR_BRIGADE_EMPTY(bb)){
008793
                 break;
008793
+            }
008793
 #ifdef DEBUGGING
008793
             len = -1;
008793
             apr_brigade_length(bb, 0, &len;;
008793
@@ -178,7 +180,6 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
008793
     conn_rec *c = r->connection;
008793
     apr_socket_t *sock = conn->sock;
008793
     conn_rec *backconn = conn->connection;
008793
-    int client_error = 0;
008793
     char *buf;
008793
     apr_bucket_brigade *header_brigade;
008793
     apr_bucket *e;
008793
@@ -224,7 +225,7 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
008793
 
008793
     pollfd.p = p;
008793
     pollfd.desc_type = APR_POLL_SOCKET;
008793
-    pollfd.reqevents = APR_POLLIN;
008793
+    pollfd.reqevents = APR_POLLIN | APR_POLLHUP;
008793
     pollfd.desc.s = sock;
008793
     pollfd.client_data = NULL;
008793
     apr_pollset_add(pollset, &pollfd);
008793
@@ -237,6 +238,9 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
008793
     r->proto_output_filters = c->output_filters;
008793
     r->input_filters = c->input_filters;
008793
     r->proto_input_filters = c->input_filters;
008793
+    /* This handler should take care of the entire connection; make it so that
008793
+     * nothing else is attempted on the connection after returning. */
008793
+    c->keepalive = AP_CONN_CLOSE;
008793
 
008793
     remove_reqtimeout(r->input_filters);
008793
 
008793
@@ -257,26 +261,28 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
008793
 
008793
             if (cur->desc.s == sock) {
008793
                 pollevent = cur->rtnevents;
008793
-                if (pollevent & APR_POLLIN) {
008793
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
008793
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02446)
008793
                                   "sock was readable");
008793
                     rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
008793
                     }
008793
-                else if ((pollevent & APR_POLLERR)
008793
-                         || (pollevent & APR_POLLHUP)) {
008793
+                else if (pollevent & APR_POLLERR) {
008793
                          rv = APR_EPIPE;
008793
                          ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
008793
-                                       "err/hup on backconn");
008793
+                                       "err on backconn");
008793
                 }
008793
-                if (rv != APR_SUCCESS)
008793
-                    client_error = 1;
008793
             }
008793
             else if (cur->desc.s == client_socket) {
008793
                 pollevent = cur->rtnevents;
008793
-                if (pollevent & APR_POLLIN) {
008793
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
008793
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02448)
008793
                                   "client was readable");
008793
                     rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
008793
+                } else if (pollevent & APR_POLLERR) {
008793
+                    rv = APR_EPIPE;
008793
+                    c->aborted = 1;
008793
+                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
008793
+                                  "error on client conn");
008793
                 }
008793
             }
008793
             else {
008793
@@ -294,9 +300,6 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
008793
     ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
008793
                   "finished with poll() - cleaning up");
008793
 
008793
-    if (client_error) {
008793
-        return HTTP_INTERNAL_SERVER_ERROR;
008793
-    }
008793
     return OK;
008793
 }
008793