diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:03:49 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:03:49 +0100 |
commit | ec0b51649cd99420792df2352b02dc949f8f293b (patch) | |
tree | a31d192b419dc5c20445983d4aff2c0a88c28d40 /src/mod_extforward.c | |
parent | a4197a3a45fd2b20d05c079d49af9fbef5fd4e2e (diff) | |
download | lighttpd-ec0b51649cd99420792df2352b02dc949f8f293b.tar.gz |
Imported Upstream version 1.4.17upstream/1.4.17
Diffstat (limited to 'src/mod_extforward.c')
-rw-r--r-- | src/mod_extforward.c | 69 |
1 files changed, 22 insertions, 47 deletions
diff --git a/src/mod_extforward.c b/src/mod_extforward.c index 23c367d..8ed336d 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <ctype.h> #include <stdlib.h> #include <string.h> @@ -11,9 +15,7 @@ #include "plugin.h" #include "inet_ntop_cache.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "configfile.h" /** * mod_extforward.c for lighttpd, by comman.kang <at> gmail <dot> com @@ -181,17 +183,6 @@ static int mod_extforward_patch_connection(server *srv, connection *con, plugin_ PATCH(forwarder); - /* LEM: The purpose of this seems to match extforward configuration - stanzas that are not in the global context, but in some sub-context. - I fear this will break contexts of the form HTTP['remote'] = . - (in the form that they do not work with the real remote, but matching on - the proxy instead). - - I'm not sure this this is all thread-safe. Is the p we are passed different - for each connection or is it global? - - mod_fastcgi does the same, so it must be safe. - */ /* skip the first, the global context */ for (i = 1; i < srv->config_context->used; i++) { data_config *dc = (data_config *)srv->config_context->data[i]; @@ -312,19 +303,9 @@ struct addrinfo *ipstr_to_sockaddr(const char *host) } -static void clean_cond_cache(server *srv, connection *con) -{ - size_t i; - - for (i = 0; i < srv->config_context->used; i++) { - data_config *dc = (data_config *)srv->config_context->data[i]; - if (dc->comp == COMP_HTTP_REMOTEIP) - { - con->cond_cache[i].result = COND_RESULT_UNSET; - con->cond_cache[i].patterncount = 0; - } - } +static void clean_cond_cache(server *srv, connection *con) { + config_cond_cache_reset_item(srv, con, COMP_HTTP_REMOTEIP); } URIHANDLER_FUNC(mod_extforward_uri_handler) { @@ -457,28 +438,22 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) { CONNECTION_FUNC(mod_extforward_restore) { plugin_data *p = p_d; - UNUSED(srv); + handler_ctx *hctx = con->plugin_ctx[p->id]; + + if (!hctx) return HANDLER_GO_ON; + + con->dst_addr = hctx->saved_remote_addr; + buffer_free(con->dst_addr_buf); + + con->dst_addr_buf = hctx->saved_remote_addr_buf; + + handler_ctx_free(hctx); + + con->plugin_ctx[p->id] = NULL; + + /* Now, clean the conf_cond cache, because we may have changed the results of tests */ + clean_cond_cache(srv, con); - /* LEM: This seems completely unuseful, as we are not using - p->conf in this function. Furthermore, it brings a - segfault if one of the conditional configuration - blocks is "SERVER['socket'] == foo", because the - socket is not known yet in the srv/con structure. - */ - /* mod_extforward_patch_connection(srv, con, p); */ - - /* restore this connection's remote ip */ - if (con->plugin_ctx[p->id]) { - handler_ctx *hctx = con->plugin_ctx[p->id]; - con->dst_addr = hctx->saved_remote_addr; - buffer_free(con->dst_addr_buf); - con->dst_addr_buf = hctx->saved_remote_addr_buf; -/* log_error_write(srv, __FILE__, __LINE__,"s","LEM: Reset dst_addr_buf"); */ - handler_ctx_free(hctx); - con->plugin_ctx[p->id] = NULL; - /* Now, clean the conf_cond cache, because we may have changed the results of tests */ - clean_cond_cache(srv, con); - } return HANDLER_GO_ON; } |