httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1669130 - in /httpd/httpd/trunk/modules/proxy: mod_proxy_connect.c mod_proxy_wstunnel.c
Date Wed, 25 Mar 2015 15:00:37 GMT
Author: ylavic
Date: Wed Mar 25 15:00:37 2015
New Revision: 1669130

URL: http://svn.apache.org/r1669130
Log:
mod_proxy_{connect,wstunnel}: follow up to r1657636.
Since rv is not used as an apr_status_t in the loop (it's logging is done by
proxy_{connect,wstunnel}_transfer() when necessary/relevent), use a boolean
instead to avoid the ugly ORs between APR error codes.

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

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c?rev=1669130&r1=1669129&r2=1669130&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c Wed Mar 25 15:00:37 2015
@@ -203,6 +203,7 @@ static int proxy_connect_handler(request
     apr_socket_t *sock;
     conn_rec *c = r->connection;
     conn_rec *backconn;
+    int done = 0;
 
     apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
     apr_status_t rv;
@@ -413,7 +414,7 @@ static int proxy_connect_handler(request
     r->proto_input_filters = c->input_filters;
 /*    r->sent_bodyct = 1;*/
 
-    while (1) { /* Infinite loop until error (one side closes the connection) */
+    do { /* Loop until done (one side closes the connection, or an error) */
         rv = apr_pollset_poll(pollset, -1, &pollcnt, &signalled);
         if (rv != APR_SUCCESS) {
             if (APR_STATUS_IS_EINTR(rv)) {
@@ -438,13 +439,14 @@ static int proxy_connect_handler(request
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01025)
                                   "sock was readable");
 #endif
-                    rv |= proxy_connect_transfer(r, backconn, c, bb, "sock");
+                    done |= proxy_connect_transfer(r, backconn, c, bb,
+                                                   "sock") != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
-                    rv |= APR_EPIPE;
-                    backconn->aborted = 1;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(01026)
                                   "err on backconn");
+                    backconn->aborted = 1;
+                    done = 1;
                 }
             }
             else if (cur->desc.s == client_socket) {
@@ -454,26 +456,24 @@ static int proxy_connect_handler(request
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01027)
                                   "client was readable");
 #endif
-                    rv |= proxy_connect_transfer(r, c, backconn, bb, "client");
+                    done |= proxy_connect_transfer(r, c, backconn, bb,
+                                                   "client") != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
-                    rv |= APR_EPIPE;
-                    c->aborted = 1;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02827)
                                   "err on client");
+                    c->aborted = 1;
+                    done = 1;
                 }
             }
             else {
-                rv |= APR_EBADF;
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01028)
                               "unknown socket in pollset");
+                done = 1;
             }
 
         }
-        if (rv != APR_SUCCESS) {
-            break;
-        }
-    }
+    } while (!done);
 
     ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                   "finished with poll() - cleaning up");

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=1669130&r1=1669129&r2=1669130&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c Wed Mar 25 15:00:37 2015
@@ -53,8 +53,9 @@ static int proxy_wstunnel_pump(ws_baton_
     apr_socket_t *client_socket = baton->client_soc;
     apr_status_t rv;
     apr_bucket_brigade *bb = baton->bb;
+    int done = 0;
 
-    while(1) { 
+    do { 
         rv = apr_pollset_poll(pollset, timeout, &pollcnt, &signalled);
         if (rv != APR_SUCCESS) {
             if (APR_STATUS_IS_EINTR(rv)) {
@@ -86,18 +87,19 @@ static int proxy_wstunnel_pump(ws_baton_
                 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");
+                    done |= proxy_wstunnel_transfer(r, backconn, c, bb,
+                                                    "sock") != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
-                    rv |= APR_EPIPE;
-                    backconn->aborted = 1;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
                             "error on backconn");
+                    backconn->aborted = 1;
+                    done = 1;
                 }
                 else { 
-                    rv |= APR_EGENERAL;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
                             "unknown event on backconn %d", pollevent);
+                    done = 1;
                 }
             }
             else if (cur->desc.s == client_socket) {
@@ -105,32 +107,30 @@ static int proxy_wstunnel_pump(ws_baton_
                 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");
+                    done |= proxy_wstunnel_transfer(r, c, backconn, bb,
+                                                    "client") != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
-                    rv |= APR_EPIPE;
-                    c->aborted = 1;
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
                             "error on client conn");
+                    c->aborted = 1;
+                    done = 1;
                 }
                 else { 
-                    rv |= APR_EGENERAL;
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02606)
                             "unknown event on client conn %d", pollevent);
+                    done = 1;
                 }
             }
             else {
-                rv |= APR_EBADF;
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02449)
                         "unknown socket in pollset");
+                done = 1;
             }
 
         }
-        if (rv != APR_SUCCESS) {
-            break;
-        }
+    } while (!done);
 
-    }
     ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
             "finished with poll() - cleaning up");
 



Mime
View raw message