diff options
author | jan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2007-04-18 09:58:52 +0000 |
---|---|---|
committer | jan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2007-04-18 09:58:52 +0000 |
commit | 7b33c77603810bbb784cb4951953fd8499b4da75 (patch) | |
tree | cf4ab4d68a37b91d7bda46b3a458a60eeae888ba | |
parent | 1a254641be9112c5a787e628eccef66411b473cb (diff) | |
download | lighttpd-7b33c77603810bbb784cb4951953fd8499b4da75.tar.gz |
added a flag to declare a conditional valid to support PHYSICAL["path"]
and similar "late" conditionals
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@1792 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | src/array.h | 4 | ||||
-rw-r--r-- | src/base.h | 2 | ||||
-rw-r--r-- | src/configfile-glue.c | 38 | ||||
-rw-r--r-- | src/configfile.c | 2 |
4 files changed, 31 insertions, 15 deletions
diff --git a/src/array.h b/src/array.h index d07334fa..169d9d64 100644 --- a/src/array.h +++ b/src/array.h @@ -93,7 +93,9 @@ typedef enum { COMP_HTTP_REMOTE_IP, COMP_HTTP_QUERY_STRING, COMP_HTTP_REQUEST_METHOD, - COMP_PHYSICAL_PATH + COMP_PHYSICAL_PATH, + + COMP_LAST_ELEMENT } comp_key_t; /* $HTTP["host"] == "incremental.home.kneschke.de" { ... } @@ -439,6 +439,8 @@ typedef struct { /**/ GTimeVal timestamps[TIME_LAST_ELEMENT]; + + int conditional_is_valid[COMP_LAST_ELEMENT]; } connection; typedef struct { diff --git a/src/configfile-glue.c b/src/configfile-glue.c index 0763feb0..8119b217 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -160,13 +160,13 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t case T_CONFIG_UNSET: break; case T_CONFIG_UNSUPPORTED: - log_error_write(srv, __FILE__, __LINE__, "ssss", "ERROR: found unsupported key:", cv[i].key, "-", (char *)(cv[i].destination)); + ERROR("found unsupported key in '%s' = '%s'", cv[i].key, (char *)(cv[i].destination)); srv->config_unsupported = 1; break; case T_CONFIG_DEPRECATED: - log_error_write(srv, __FILE__, __LINE__, "ssss", "ERROR: found deprecated key:", cv[i].key, "-", (char *)(cv[i].destination)); + ERROR("found deprecated key in '%s' = '%s'", cv[i].key, (char *)(cv[i].destination)); srv->config_deprecated = 1; @@ -236,6 +236,12 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat } } + if (!con->conditional_is_valid[dc->comp]) { + TRACE("cond[%d] is valid: %d", dc->comp, con->conditional_is_valid[dc->comp]); + + return COND_RESULT_UNSET; + } + /* pass the rules */ switch (dc->comp) { @@ -402,10 +408,9 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat break; } - case COMP_PHYSICAL_PATH: { + case COMP_PHYSICAL_PATH: l = con->physical.path; break; - } default: return COND_RESULT_FALSE; } @@ -419,9 +424,12 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat } if (con->conf.log_condition_handling) { - log_error_write(srv, __FILE__, __LINE__, "bsbsb", dc->comp_key, - "(", l, ") compare to", dc->string); + TRACE("'%s': '%s' is matched against '%s'", + BUF_STR(dc->comp_key), + BUF_STR(l), + BUF_STR(dc->string)); } + switch(dc->cond) { case CONFIG_COND_NE: case CONFIG_COND_EQ: @@ -467,14 +475,13 @@ static cond_result_t config_check_cond_cached(server *srv, connection *con, data if (COND_RESULT_UNSET == caches[dc->context_ndx].result) { if (con->conf.log_condition_handling) { - log_error_write(srv, __FILE__, __LINE__, "sds", "=== start of", dc->context_ndx, "condition block ==="); + TRACE("=== start of %d condition block ===", dc->context_ndx); } if (COND_RESULT_TRUE == (caches[dc->context_ndx].result = config_check_cond_nocache(srv, con, dc))) { if (dc->next) { data_config *c; if (con->conf.log_condition_handling) { - log_error_write(srv, __FILE__, __LINE__, "s", - "setting remains of chaining to false"); + TRACE("setting remains of chaining to %s", "false"); } for (c = dc->next; c; c = c->next) { caches[c->context_ndx].result = COND_RESULT_FALSE; @@ -482,14 +489,14 @@ static cond_result_t config_check_cond_cached(server *srv, connection *con, data } } if (con->conf.log_condition_handling) { - log_error_write(srv, __FILE__, __LINE__, "dss", dc->context_ndx, - "result:", + TRACE("[%d] result: %s", + dc->context_ndx, caches[dc->context_ndx].result == COND_RESULT_TRUE ? "true" : "false"); } } else { if (con->conf.log_condition_cache_handling) { - log_error_write(srv, __FILE__, __LINE__, "dss", dc->context_ndx, - "(cached) result:", + TRACE("[%d] (cached) result: %s", + dc->context_ndx, caches[dc->context_ndx].result == COND_RESULT_TRUE ? "true" : "false"); } } @@ -497,9 +504,9 @@ static cond_result_t config_check_cond_cached(server *srv, connection *con, data } void config_cond_cache_reset(server *srv, connection *con) { -#if COND_RESULT_UNSET size_t i; +#if COND_RESULT_UNSET for (i = srv->config_context->used - 1; i >= 0; i --) { con->cond_cache[i].result = COND_RESULT_UNSET; con->cond_cache[i].patterncount = 0; @@ -507,6 +514,9 @@ void config_cond_cache_reset(server *srv, connection *con) { #else memset(con->cond_cache, 0, sizeof(cond_cache_t) * srv->config_context->used); #endif + for (i = 0; i < COMP_LAST_ELEMENT; i++) { + con->conditional_is_valid[i] = 0; + } } int config_check_cond(server *srv, connection *con, data_config *dc) { diff --git a/src/configfile.c b/src/configfile.c index 30225c0e..cade3975 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -293,6 +293,8 @@ int config_setup_connection(server *srv, connection *con) { int config_patch_connection(server *srv, connection *con, comp_key_t comp) { size_t i, j; + con->conditional_is_valid[comp] = 1; + /* 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]; |