On Sun, 1 Jan 2012, Eric Covener wrote:
Can anyone more familiar with the code verify this? Steffen, maybe you
can try the change and see if it helps?
I think there are a few additional wrinkles -- I couldn't repro after
this but no confident about what's right with the addr handling:
http://people.apache.org/~covener/patches/trunk-proxy_toggle_ports.diff
Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c (revision 1226300)
+++ modules/proxy/proxy_util.c (working copy)
@@ -2029,7 +2029,7 @@
* TODO: Handle this much better...
*/
if (!conn->hostname || !worker->s->is_address_reusable ||
- worker->s->disablereuse ||
+ worker->s->disablereuse || conn->port != uri->port ||
(r->connection->keepalives &&
(r->proxyreq == PROXYREQ_PROXY || r->proxyreq == PROXYREQ_REVERSE) &&
(strcasecmp(conn->hostname, uri->hostname) != 0) ) ) {
The different handling of conn->port and conn->hostname doesn't look
right to me. Can the r->proxyreq check actually be false at this point or is
it simply redundant? And shouldn't the strcasecmp(conn->hostname,
uri->hostname) check be done regardless of r->connection->keepalives?
@@ -2076,6 +2076,8 @@
conn->pool);
}
else if (!worker->cp->addr) {
+ conn->port = uri->port;
+ conn->hostname = apr_pstrdup(conn->pool, uri->hostname);
if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, APLOGNO(00945)
"lock");
return HTTP_INTERNAL_SERVER_ERROR;
@@ -2097,7 +2099,9 @@
}
}
else {
- conn->addr = worker->cp->addr;
+ if (!conn->addr) {
+ conn->addr = worker->cp->addr;
+ }
}
/* Close a possible existing socket if we are told to do so */
if (conn->close) {
<virtualhost *:80>
RewriteEngine on
RewriteRule ^/a http://localhost:81/a [P]
RewriteRule ^/b http://localhost:82/b [P]
</virtualhost>
<virtualhost *:81>
AliasMatch ^/a$ /home/covener/SRC/httpd-trunk/built/icons/a.gif
</virtualhost>
<virtualhost *:82>
AliasMatch ^/b$ /home/covener/SRC/httpd-trunk/built/icons/a.gif
</virtualhost>
Before any patch, as simple as a/b fails. The worker->cp->addr copy
issue fails with something like a/b/b.