Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Cute little bug - fixed.

From: Graham Leggett <minfrin(at)sharp.fm>
Date: Tue Apr 10 2001 - 18:57:11 EDT


Hi all,

I have got a patch that fixes the hassles we've been having with the proxy.

The basic problem was one of the storage of the downstream connection between requests was not thread safe - which caused all manner of hassles and odd behavior. The solution was to place the downstream conn_rec inside the upstream conn_rec.

This patch adds a single field to conn_rec. This was a problem last time, as people said it should be stored in the configuration record. Unfortunately this isn't thread safe...

Should I post this to new-httpd again?

Regards,
Graham

-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

diff -u3 -r --exclude=CVS ../../pristine/httpd-2.0/include/httpd.h httpd-2.0/include/httpd.h --- ../../pristine/httpd-2.0/include/httpd.h Tue Apr 3 20:09:24 2001 +++ httpd-2.0/include/httpd.h Tue Apr 10 23:49:11 2001
@@ -834,6 +834,8 @@
server_rec *base_server; /** used by http_vhost.c */ void *vhost_lookup_data; + /** used by mod_proxy.c */ + conn_rec *downstream; /* Information about the connection itself */

diff -u3 -r --exclude=CVS httpd-proxy2/module-2.0/proxy_http.c httpd-2.0/modules/proxy/proxy_http.c --- httpd-proxy2/module-2.0/proxy_http.c Tue Apr 10 23:27:28 2001 +++ httpd-2.0/modules/proxy/proxy_http.c Wed Apr 11 00:25:21 2001
@@ -285,11 +285,12 @@
* open, or whether it should be closed and a new socket created. */ /* see memory note above */ - if (conf->connection) { - if ((conf->id == c->id) && - (conf->connectport == connectport) && - (conf->connectname) && - (!apr_strnatcasecmp(conf->connectname,connectname))) { + if (c->downstream) { + int port = 0; + if ((c->downstream->id == c->id) && + (APR_SUCCESS == apr_sockaddr_port_get(&port, c->downstream->remote_addr)) && + (port == connectport) && + (!apr_strnatcasecmp(c->downstream->remote_host,connectname))) { ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: keepalive address match (keep original socket)"); }
@@ -297,8 +298,8 @@
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: keepalive address mismatch / connection has" " changed (close old socket (%s/%s, %d/%d))", - connectname, conf->connectname, - connectport, conf->connectport); + connectname, c->downstream->remote_host, + connectport, port); apr_socket_close(conf->connection->client_socket); conf->connection = NULL; }
@@ -306,11 +307,11 @@
/* get a socket - either a keepalive one, or a new one */ new = 1; - if ((conf->id == c->id) && (conf->connection)) { + if ((c->downstream) && (c->downstream->id == c->id)) { /* use previous keepalive socket */ - sock = conf->connection->client_socket; - origin = conf->connection; + origin = c->downstream; + sock = origin->client_socket; new = 0; /* reset the connection filters */
@@ -322,7 +323,7 @@
if (new) { /* create a new socket */ - conf->connection = NULL; + c->downstream = NULL; /* see memory note above */ if ((apr_socket_create(&sock, APR_INET, SOCK_STREAM, c->pool)) != APR_SUCCESS) {
@@ -399,10 +400,8 @@
apr_socket_close(sock); return HTTP_INTERNAL_SERVER_ERROR; } - conf->id = r->connection->id; - conf->connectname = connectname; - conf->connectport = connectport; - conf->connection = origin; + c->downstream = origin; + c->downstream->remote_host = apr_pstrdup(c->pool, connectname); ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: connection complete");
@@ -581,7 +580,7 @@
if (APR_SUCCESS != (rv = ap_proxy_string_read(origin, bb, buffer, sizeof(buffer)))) { apr_socket_close(sock); - conf->connection = NULL; + c->downstream = NULL; ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "proxy: error reading status line from remote server %s", connectname);
@@ -602,7 +601,7 @@
/* If not an HTTP/1 message or if the status line was > 8192 bytes */ else if ((buffer[5] != '1') || (len >= sizeof(buffer)-1)) { apr_socket_close(sock); - conf->connection = NULL; + c->downstream = NULL; return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p, "Corrupt status line returned by remote server: ", buffer, NULL)); }
@@ -752,7 +751,7 @@
*/ if (close || (r->proto_num < HTTP_VERSION(1,1))) { apr_socket_close(sock); - conf->connection = NULL; + c->downstream = NULL; } return OK; Received on Tue Apr 10 23:00:06 2001

Do you need help?X

This archive was generated by hypermail 2.1.8 : Thu Aug 24 2006 - 14:53:15 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library