You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2014/04/13 19:21:51 UTC

svn commit: r1587053 - in /httpd/httpd/trunk: CHANGES modules/proxy/mod_proxy_wstunnel.c

Author: covener
Date: Sun Apr 13 17:21:50 2014
New Revision: 1587053

URL: http://svn.apache.org/r1587053
Log:
cleanup wstunnel error handling

Submitted By: covener, ylavic, Edward Lu
Commited By: covener


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1587053&r1=1587052&r2=1587053&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun Apr 13 17:21:50 2014
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy_wstunnel: Don't issue AH02447 and log a 500 on routine 
+     hangups from websockets origin servers. PR 56299
+     [Yann Ylavic, Edward Lu <Chaosed0 gmail com>, Eric Covener] 
+
   *) mod_proxy_wstunnel: Don't pool backend websockets connections,
      because we need to handshake every time. PR 55890.
      [Eric Covener]

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c?rev=1587053&r1=1587052&r2=1587053&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c Sun Apr 13 17:21:50 2014
@@ -34,7 +34,6 @@ static int proxy_wstunnel_transfer(reque
                                      apr_bucket_brigade *bb, char *name);
 
 static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout) {
-    int client_error = 0;
     request_rec *r = baton->r;
     conn_rec *c = r->connection;
     proxy_conn_rec *conn = baton->proxy_connrec;
@@ -72,38 +71,34 @@ static int proxy_wstunnel_pump(ws_baton_
 
             if (cur->desc.s == sock) {
                 pollevent = cur->rtnevents;
-                if (pollevent & APR_POLLIN) {
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
                             "sock was readable");
                     rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
                 }
-                else if ((pollevent & APR_POLLERR)
-                        || (pollevent & APR_POLLHUP)) {
+                else if (pollevent & APR_POLLERR) {
                     rv = APR_EPIPE;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
-                            "err/hup on backconn");
+                            "error on backconn");
                 }
                 else { 
                     rv = APR_EGENERAL;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
                             "unknown event on backconn %d", pollevent);
                 }
-                if (rv != APR_SUCCESS)
-                    client_error = 1;
             }
             else if (cur->desc.s == client_socket) {
                 pollevent = cur->rtnevents;
-                if (pollevent & APR_POLLIN) {
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
                             "client was readable");
                     rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
                 }
-                else if ((pollevent & APR_POLLERR)
-                        || (pollevent & APR_POLLHUP)) {
+                else if (pollevent & APR_POLLERR) {
                     rv = APR_EPIPE;
                     c->aborted = 1;
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
-                            "err/hup on client conn");
+                            "error on client conn");
                 }
                 else { 
                     rv = APR_EGENERAL;
@@ -126,9 +121,6 @@ static int proxy_wstunnel_pump(ws_baton_
     ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
             "finished with poll() - cleaning up");
 
-    if (client_error) {
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
     return OK;
 }
 
@@ -239,10 +231,12 @@ static int proxy_wstunnel_transfer(reque
         rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
                             APR_NONBLOCK_READ, AP_IOBUFSIZE);
         if (rv == APR_SUCCESS) {
-            if (c_o->aborted)
+            if (c_o->aborted) {
                 return APR_EPIPE;
-            if (APR_BRIGADE_EMPTY(bb))
+            }
+            if (APR_BRIGADE_EMPTY(bb)) {
                 break;
+            }
 #ifdef DEBUGGING
             len = -1;
             apr_brigade_length(bb, 0, &len);
@@ -359,7 +353,7 @@ static int ap_proxy_wstunnel_request(apr
 
     pollfd.p = p;
     pollfd.desc_type = APR_POLL_SOCKET;
-    pollfd.reqevents = APR_POLLIN;
+    pollfd.reqevents = APR_POLLIN | APR_POLLHUP;
     pollfd.desc.s = sock;
     pollfd.client_data = NULL;
     apr_pollset_add(pollset, &pollfd);
@@ -374,6 +368,9 @@ static int ap_proxy_wstunnel_request(apr
     r->proto_output_filters = c->output_filters;
     r->input_filters = c->input_filters;
     r->proto_input_filters = c->input_filters;
+    /* This handler should take care of the entire connection; make it so that
+     * nothing else is attempted on the connection after returning. */
+    c->keepalive = AP_CONN_CLOSE;
 
 
     baton->r = r;