Author: jfrederic.clere(a)jboss.com
Date: 2008-05-16 10:42:22 -0400 (Fri, 16 May 2008)
New Revision: 1609
Added:
sandbox/httpd/src/patch.reversed.txt.r657083
Log:
Patch to get the reversed logic to work.
Added: sandbox/httpd/src/patch.reversed.txt.r657083
===================================================================
--- sandbox/httpd/src/patch.reversed.txt.r657083 (rev 0)
+++ sandbox/httpd/src/patch.reversed.txt.r657083 2008-05-16 14:42:22 UTC (rev 1609)
@@ -0,0 +1,212 @@
+Index: modules/proxy/mod_proxy_ajp.c
+===================================================================
+--- modules/proxy/mod_proxy_ajp.c (revision 657083)
++++ modules/proxy/mod_proxy_ajp.c (working copy)
+@@ -495,6 +495,7 @@
+ apr_port_t proxyport)
+ {
+ int status;
++ apr_status_t rv;
+ char server_portstr[32];
+ conn_rec *origin = NULL;
+ proxy_conn_rec *backend = NULL;
+@@ -554,7 +555,12 @@
+ goto cleanup;
+
+ /* Step Two: Make the Connection */
+- if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
++ if (worker->opaque) {
++ rv = ap_proxy_accept_backend(scheme, backend, worker, r->server);
++ } else {
++ rv = ap_proxy_connect_backend(scheme, backend, worker, r->server);
++ }
++ if (rv) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "proxy: AJP: failed to make connection to backend: %s",
+ backend->hostname);
+Index: modules/proxy/proxy_util.c
+===================================================================
+--- modules/proxy/proxy_util.c (revision 657083)
++++ modules/proxy/proxy_util.c (working copy)
+@@ -2139,6 +2139,135 @@
+ }
+ #endif /* USE_ALTERNATE_IS_CONNECTED */
+
++/*
++ * Accept a connection from the backend server
++ */
++PROXY_DECLARE(int) ap_proxy_accept_backend(const char *proxy_function,
++ proxy_conn_rec *conn,
++ proxy_worker *worker,
++ server_rec *s)
++{
++ apr_status_t rv;
++ int connected = 0;
++ int loglevel;
++ apr_sockaddr_t *backend_addr = conn->addr;
++ apr_socket_t *newsock;
++ void *sconf = s->module_config;
++ proxy_server_conf *conf =
++ (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
++
++ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
++ "ap_proxy_accept_backend");
++ if (conn->sock) {
++ /*
++ * This increases the connection pool size
++ * but the number of dropped connections is
++ * relatively small compared to connection lifetime
++ */
++ if (!(connected = is_socket_connected(conn->sock))) {
++ apr_socket_close(conn->sock);
++ conn->sock = NULL;
++ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
++ "proxy: %s: backend socket is disconnected.",
++ proxy_function);
++ }
++ }
++
++ /* If we aren't connected we have to accept a connection */
++ while (!connected) {
++ if ((rv = apr_socket_accept(&newsock, worker->opaque,
++ conn->pool)) != APR_SUCCESS) {
++ loglevel = backend_addr->next ? APLOG_DEBUG : APLOG_ERR;
++ ap_log_error(APLOG_MARK, loglevel, rv, s,
++ "proxy: %s: error creating fam %d socket for target
%s",
++ proxy_function,
++ backend_addr->family,
++ worker->hostname);
++ /*
++ * XXX: We loop... But that is a just a test...
++ */
++ continue;
++ }
++
++#if !defined(TPF) && !defined(BEOS)
++ if (worker->recv_buffer_size > 0 &&
++ (rv = apr_socket_opt_set(newsock, APR_SO_RCVBUF,
++ worker->recv_buffer_size))) {
++ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
++ "apr_socket_opt_set(SO_RCVBUF): Failed to set "
++ "ProxyReceiveBufferSize, using default");
++ }
++#endif
++
++ rv = apr_socket_opt_set(newsock, APR_TCP_NODELAY, 1);
++ if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) {
++ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
++ "apr_socket_opt_set(APR_TCP_NODELAY): "
++ "Failed to set");
++ }
++
++ /* Set a timeout on the socket */
++ if (worker->timeout_set == 1) {
++ apr_socket_timeout_set(newsock, worker->timeout);
++ }
++ else if (conf->timeout_set == 1) {
++ apr_socket_timeout_set(newsock, conf->timeout);
++ }
++ else {
++ apr_socket_timeout_set(newsock, s->timeout);
++ }
++ /* Set a keepalive option */
++ if (worker->keepalive) {
++ if ((rv = apr_socket_opt_set(newsock,
++ APR_SO_KEEPALIVE, 1)) != APR_SUCCESS) {
++ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
++ "apr_socket_opt_set(SO_KEEPALIVE): Failed to
set"
++ " Keepalive");
++ }
++ }
++ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
++ "proxy: %s: fam %d socket created to connect to %s",
++ proxy_function, backend_addr->family, worker->hostname);
++
++ /* if an error occurred, loop round and try again */
++ if (rv != APR_SUCCESS) {
++ apr_socket_close(newsock);
++ loglevel = backend_addr->next ? APLOG_DEBUG : APLOG_ERR;
++ ap_log_error(APLOG_MARK, loglevel, rv, s,
++ "proxy: %s: attempt to connect to %pI (%s) failed",
++ proxy_function,
++ backend_addr,
++ worker->hostname);
++ backend_addr = backend_addr->next;
++ continue;
++ }
++
++ conn->sock = newsock;
++ connected = 1;
++ }
++ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
++ "ap_proxy_accept_backend: CONNECTED");
++ /*
++ * Put the entire worker to error state if
++ * the PROXY_WORKER_IGNORE_ERRORS flag is not set.
++ * Altrough some connections may be alive
++ * no further connections to the worker could be made
++ */
++ if (!connected && PROXY_WORKER_IS_USABLE(worker) &&
++ !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) {
++ worker->s->status |= PROXY_WORKER_IN_ERROR;
++ worker->s->error_time = apr_time_now();
++ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
++ "ap_proxy_connect_backend disabling worker for (%s)",
++ worker->hostname);
++ }
++ else {
++ worker->s->error_time = 0;
++ worker->s->retries = 0;
++ }
++ return connected ? OK : DECLINED;
++}
++
+ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
+ proxy_conn_rec *conn,
+ proxy_worker *worker,
+Index: modules/proxy/mod_proxy.c
+===================================================================
+--- modules/proxy/mod_proxy.c (revision 657083)
++++ modules/proxy/mod_proxy.c (working copy)
+@@ -415,6 +415,8 @@
+ (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
+
+ /* Ick... msvc (perhaps others) promotes ternary short results to int */
++ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
++ "proxy_detect");
+
+ if (conf->req && r->parsed_uri.scheme) {
+ /* but it might be something vhosted */
+@@ -453,6 +455,8 @@
+ char *found = NULL;
+ int mismatch = 0;
+
++ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
++ "proxy_trans");
+ if (r->proxyreq) {
+ /* someone has already set up the proxy, it was possibly ourselves
+ * in proxy_detect
+@@ -690,6 +694,8 @@
+ struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts;
+
+ /* is this for us? */
++ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
++ "proxy_handler %s %d %s", r->handler, r->proxyreq,
r->filename);
+ if (!r->proxyreq || !r->filename || strncmp(r->filename,
"proxy:", 6) != 0)
+ return DECLINED;
+
+Index: modules/proxy/mod_proxy.h
+===================================================================
+--- modules/proxy/mod_proxy.h (revision 657083)
++++ modules/proxy/mod_proxy.h (working copy)
+@@ -701,6 +701,10 @@
+ proxy_conn_rec *conn,
+ proxy_worker *worker,
+ server_rec *s);
++PROXY_DECLARE(int) ap_proxy_accept_backend(const char *proxy_function,
++ proxy_conn_rec *conn,
++ proxy_worker *worker,
++ server_rec *s);
+ /**
+ * Make a connection record for backend connection
+ * @param proxy_function calling proxy scheme (http, ajp, ...)