Mailing List Archive

svn commit: r1895304 - in /httpd/httpd/trunk: changes-entries/proxy_half_close.txt modules/proxy/mod_proxy.h modules/proxy/proxy_util.c
Author: ylavic
Date: Wed Nov 24 17:49:47 2021
New Revision: 1895304

URL: http://svn.apache.org/viewvc?rev=1895304&view=rev
Log:
mod_proxy: SetEnv proxy-nohalfclose to disable half-close tunneling. PR 65662.

Some connect/wstunnel protocols might want half-close forwarding while some
might not, let's provide an r->subprocess_env opt-out.


Added:
httpd/httpd/trunk/changes-entries/proxy_half_close.txt
Modified:
httpd/httpd/trunk/modules/proxy/mod_proxy.h
httpd/httpd/trunk/modules/proxy/proxy_util.c

Added: httpd/httpd/trunk/changes-entries/proxy_half_close.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/proxy_half_close.txt?rev=1895304&view=auto
==============================================================================
--- httpd/httpd/trunk/changes-entries/proxy_half_close.txt (added)
+++ httpd/httpd/trunk/changes-entries/proxy_half_close.txt Wed Nov 24 17:49:47 2021
@@ -0,0 +1,2 @@
+ *) mod_proxy: SetEnv proxy-nohalfclose (or alike) allows to disable TCP
+ half-close forwarding when tunneling protocols. [Yann Ylavic]

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1895304&r1=1895303&r2=1895304&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Wed Nov 24 17:49:47 2021
@@ -1360,7 +1360,8 @@ typedef struct {
proxy_tunnel_conn_t *client,
*origin;
apr_size_t read_buf_size;
- int replied;
+ int replied; /* TODO 2.5+: one bit to merge in below bitmask */
+ unsigned int nohalfclose :1;
} proxy_tunnel_rec;

/**

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1895304&r1=1895303&r2=1895304&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Wed Nov 24 17:49:47 2021
@@ -4818,6 +4818,11 @@ PROXY_DECLARE(apr_status_t) ap_proxy_tun
c_i->keepalive = AP_CONN_CLOSE;
c_o->keepalive = AP_CONN_CLOSE;

+ /* Disable half-close forwarding for this request? */
+ if (apr_table_get(r->subprocess_env, "proxy-nohalfclose")) {
+ tunnel->nohalfclose = 1;
+ }
+
/* Start with POLLOUT and let ap_proxy_tunnel_run() schedule both
* directions when there are no output data pending (anymore).
*/
@@ -4920,6 +4925,12 @@ static int proxy_tunnel_transfer(proxy_t
ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, tunnel->r,
"proxy: %s: %s read shutdown",
tunnel->scheme, in->name);
+ if (tunnel->nohalfclose) {
+ /* No half-close forwarding, we are done both ways as
+ * soon as one side shuts down.
+ */
+ return DONE;
+ }
in->down_in = 1;
}
else {
@@ -5093,11 +5104,14 @@ PROXY_DECLARE(int) ap_proxy_tunnel_run(p
} while (!client->down_out || !origin->down_out);

done:
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(10223)
+ "proxy: %s: tunneling returns (%i)", scheme, status);
if (client->bytes_out > 0) {
tunnel->replied = 1;
}
- ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(10223)
- "proxy: %s: tunneling returns (%i)", scheme, status);
+ if (status == DONE) {
+ status = OK;
+ }
return status;
}