httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r1727567 - /httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c
Date Fri, 29 Jan 2016 12:36:38 GMT
Author: rpluem
Date: Fri Jan 29 12:36:38 2016
New Revision: 1727567

URL: http://svn.apache.org/viewvc?rev=1727567&view=rev
Log:
* Transform the buckets to the correct lifetime of the brigade, connection and filter stack
that processes it.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy_connect.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=1727567&r1=1727566&r2=1727567&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c Fri Jan 29 12:36:38 2016
@@ -145,7 +145,8 @@ static int proxy_connect_canon(request_r
 
 /* read available data (in blocks of CONN_BLKSZ) from c_i and copy to c_o */
 static int proxy_connect_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
-                                  apr_bucket_brigade *bb, char *name)
+                                  apr_bucket_brigade *bb_i,
+                                  apr_bucket_brigade *bb_o, char *name)
 {
     int rv;
 #ifdef DEBUGGING
@@ -153,24 +154,25 @@ static int proxy_connect_transfer(reques
 #endif
 
     do {
-        apr_brigade_cleanup(bb);
-        rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
+        apr_brigade_cleanup(bb_i);
+        rv = ap_get_brigade(c_i->input_filters, bb_i, AP_MODE_READBYTES,
                             APR_NONBLOCK_READ, CONN_BLKSZ);
         if (rv == APR_SUCCESS) {
             if (c_o->aborted)
                 return APR_EPIPE;
-            if (APR_BRIGADE_EMPTY(bb))
+            if (APR_BRIGADE_EMPTY(bb_i))
                 break;
 #ifdef DEBUGGING
             len = -1;
-            apr_brigade_length(bb, 0, &len);
+            apr_brigade_length(bb_i, 0, &len);
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01016)
                           "read %" APR_OFF_T_FMT
                           " bytes from %s", len, name);
 #endif
-            rv = ap_pass_brigade(c_o->output_filters, bb);
+            ap_proxy_buckets_lifetime_transform(r, bb_i, bb_o);
+            rv = ap_pass_brigade(c_o->output_filters, bb_o);
             if (rv == APR_SUCCESS) {
-                ap_fflush(c_o->output_filters, bb);
+                ap_fflush(c_o->output_filters, bb_o);
             }
             else {
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01017)
@@ -205,7 +207,8 @@ static int proxy_connect_handler(request
     conn_rec *backconn;
     int done = 0;
 
-    apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
+    apr_bucket_brigade *bb_front = apr_brigade_create(p, c->bucket_alloc);
+    apr_bucket_brigade *bb_back;
     apr_status_t rv;
     apr_size_t nbytes;
     char buffer[HUGE_STRING_LEN];
@@ -360,6 +363,9 @@ static int proxy_connect_handler(request
     apr_table_setn(r->notes, "proxy-source-port", apr_psprintf(r->pool, "%hu",
                    backconn->local_addr->port));
 
+
+    bb_back = apr_brigade_create(p, backconn->bucket_alloc);
+
     /* If we are connecting through a remote proxy, we need to pass
      * the CONNECT request on to it.
      */
@@ -368,24 +374,24 @@ static int proxy_connect_handler(request
      */
         ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                       "sending the CONNECT request to the remote proxy");
-        ap_fprintf(backconn->output_filters, bb,
+        ap_fprintf(backconn->output_filters, bb_back,
                    "CONNECT %s HTTP/1.0" CRLF, r->uri);
-        ap_fprintf(backconn->output_filters, bb,
+        ap_fprintf(backconn->output_filters, bb_back,
                    "Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
-        ap_fflush(backconn->output_filters, bb);
+        ap_fflush(backconn->output_filters, bb_back);
     }
     else {
         ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "Returning 200 OK");
         nbytes = apr_snprintf(buffer, sizeof(buffer),
                               "HTTP/1.0 200 Connection Established" CRLF);
         ap_xlate_proto_to_ascii(buffer, nbytes);
-        ap_fwrite(c->output_filters, bb, buffer, nbytes);
+        ap_fwrite(c->output_filters, bb_front, buffer, nbytes);
         nbytes = apr_snprintf(buffer, sizeof(buffer),
                               "Proxy-agent: %s" CRLF CRLF,
                               ap_get_server_banner());
         ap_xlate_proto_to_ascii(buffer, nbytes);
-        ap_fwrite(c->output_filters, bb, buffer, nbytes);
-        ap_fflush(c->output_filters, bb);
+        ap_fwrite(c->output_filters, bb_front, buffer, nbytes);
+        ap_fflush(c->output_filters, bb_front);
 #if 0
         /* This is safer code, but it doesn't work yet.  I'm leaving it
          * here so that I can fix it later.
@@ -439,8 +445,9 @@ static int proxy_connect_handler(request
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01025)
                                   "sock was readable");
 #endif
-                    done |= proxy_connect_transfer(r, backconn, c, bb,
-                                                   "sock") != APR_SUCCESS;
+                    done |= proxy_connect_transfer(r, backconn, c, bb_back,
+                                                   bb_front, "sock")
+                                                   != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(01026)
@@ -456,8 +463,9 @@ static int proxy_connect_handler(request
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01027)
                                   "client was readable");
 #endif
-                    done |= proxy_connect_transfer(r, c, backconn, bb,
-                                                   "client") != APR_SUCCESS;
+                    done |= proxy_connect_transfer(r, c, backconn, bb_front,
+                                                   bb_back, "client")
+                                                   != APR_SUCCESS;
                 }
                 else if (pollevent & APR_POLLERR) {
                     ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02827)



Mime
View raw message