altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone

Blame SOURCES/httpd-2.4.6-r1587053.patch

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