[core] improve conditional enabling (thx Gwenlliana, #2598)

instead of looping over all config blocks for each conditional var that
gets enabled, enable them all and run over them once.

Right now it seems we actually set all variables at once in normal
config handling (SNI only sets a subset); future modifications
might introduce new variables which are activated at a later stage
(physical path related for example).

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3083 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/heads/lighttpd-1.4.x
Stefan Bühler 7 years ago
parent ad65603ec0
commit c033a1966e
  1. 1
      NEWS
  2. 4
      src/configfile.c
  3. 3
      src/configfile.h
  4. 1
      src/connections.c
  5. 7
      src/network.c
  6. 2
      src/plugin.h
  7. 24
      src/response.c

@ -15,6 +15,7 @@ NEWS
* [configparser] don't continue after parse error (fixes #2717)
* [core] never evaluate else branches until the previous branches are ready (fixes #2598)
* [core] fix conditional cache handling
* [core] improve conditional enabling (thx Gwenlliana, #2598)
- 1.4.39 - 2016-01-02
* [core] fix memset_s call (fixes #2698)

@ -383,11 +383,9 @@ int config_setup_connection(server *srv, connection *con) {
return 0;
}
int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
int config_patch_connection(server *srv, connection *con) {
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];

@ -21,6 +21,9 @@ int config_parse_file(server *srv, config_t *context, const char *fn);
int config_parse_cmd(server *srv, config_t *context, const char *cmd);
data_unset *configparser_merge_data(data_unset *op1, const data_unset *op2);
int config_setup_connection(server *srv, connection *con);
int config_patch_connection(server *srv, connection *con);
void config_cond_cache_reset(server *srv, connection *con);
void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item);

@ -4,6 +4,7 @@
#include "connections.h"
#include "fdevent.h"
#include "configfile.h"
#include "request.h"
#include "response.h"
#include "network.h"

@ -108,9 +108,10 @@ static int network_ssl_servername_callback(SSL *ssl, int *al, server *srv) {
config_cond_cache_reset(srv, con);
config_setup_connection(srv, con);
config_patch_connection(srv, con, COMP_SERVER_SOCKET);
config_patch_connection(srv, con, COMP_HTTP_SCHEME);
config_patch_connection(srv, con, COMP_HTTP_HOST);
con->conditional_is_valid[COMP_SERVER_SOCKET] = 1;
con->conditional_is_valid[COMP_HTTP_SCHEME] = 1;
con->conditional_is_valid[COMP_HTTP_HOST] = 1;
config_patch_connection(srv, con);
if (NULL == con->conf.ssl_pemfile_x509 || NULL == con->conf.ssl_pemfile_pkey) {
/* x509/pkey available <=> pemfile was set <=> pemfile got patched: so this should never happen, unless you nest $SERVER["socket"] */

@ -84,8 +84,6 @@ handler_t plugins_call_cleanup(server *srv);
int config_insert_values_global(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
int config_insert_values_internal(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
int config_setup_connection(server *srv, connection *con);
int config_patch_connection(server *srv, connection *con, comp_key_t comp);
int config_check_cond(server *srv, connection *con, data_config *dc);
int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n);

@ -246,7 +246,6 @@ handler_t http_response_prepare(server *srv, connection *con) {
if (con->conf.log_condition_handling) {
log_error_write(srv, __FILE__, __LINE__, "s", "run condition");
}
config_patch_connection(srv, con, COMP_SERVER_SOCKET); /* SERVERsocket */
/**
* prepare strings
@ -279,15 +278,6 @@ handler_t http_response_prepare(server *srv, connection *con) {
buffer_copy_buffer(con->uri.authority, con->request.http_host);
buffer_to_lower(con->uri.authority);
config_patch_connection(srv, con, COMP_HTTP_SCHEME); /* Scheme: */
config_patch_connection(srv, con, COMP_HTTP_HOST); /* Host: */
config_patch_connection(srv, con, COMP_HTTP_REMOTE_IP); /* Client-IP */
config_patch_connection(srv, con, COMP_HTTP_REFERER); /* Referer: */
config_patch_connection(srv, con, COMP_HTTP_USER_AGENT);/* User-Agent: */
config_patch_connection(srv, con, COMP_HTTP_LANGUAGE); /* Accept-Language: */
config_patch_connection(srv, con, COMP_HTTP_COOKIE); /* Cookie: */
config_patch_connection(srv, con, COMP_HTTP_REQUEST_METHOD); /* REQUEST_METHOD */
/** their might be a fragment which has to be cut away */
if (NULL != (qstr = strchr(con->request.uri->ptr, '#'))) {
buffer_string_set_length(con->request.uri, qstr - con->request.uri->ptr);
@ -318,8 +308,18 @@ handler_t http_response_prepare(server *srv, connection *con) {
buffer_path_simplify(con->uri.path, srv->tmp_buf);
}
config_patch_connection(srv, con, COMP_HTTP_URL); /* HTTPurl */
config_patch_connection(srv, con, COMP_HTTP_QUERY_STRING); /* HTTPqs */
con->conditional_is_valid[COMP_SERVER_SOCKET] = 1; /* SERVERsocket */
con->conditional_is_valid[COMP_HTTP_SCHEME] = 1; /* Scheme: */
con->conditional_is_valid[COMP_HTTP_HOST] = 1; /* Host: */
con->conditional_is_valid[COMP_HTTP_REMOTE_IP] = 1; /* Client-IP */
con->conditional_is_valid[COMP_HTTP_REFERER] = 1; /* Referer: */
con->conditional_is_valid[COMP_HTTP_USER_AGENT] = /* User-Agent: */
con->conditional_is_valid[COMP_HTTP_LANGUAGE] = 1; /* Accept-Language: */
con->conditional_is_valid[COMP_HTTP_COOKIE] = 1; /* Cookie: */
con->conditional_is_valid[COMP_HTTP_REQUEST_METHOD] = 1; /* REQUEST_METHOD */
con->conditional_is_valid[COMP_HTTP_URL] = 1; /* HTTPurl */
con->conditional_is_valid[COMP_HTTP_QUERY_STRING] = 1; /* HTTPqs */
config_patch_connection(srv, con);
#ifdef USE_OPENSSL
if (con->srv_socket->is_ssl && con->conf.ssl_verifyclient) {

Loading…
Cancel
Save