diff --git a/src/mod_access.c b/src/mod_access.c index b2c81cfb..3769845b 100644 --- a/src/mod_access.c +++ b/src/mod_access.c @@ -85,16 +85,16 @@ SETDEFAULTS_FUNC(mod_access_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_access_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_access_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(access_deny); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -111,34 +111,16 @@ static int mod_access_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_access_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - - UNUSED(srv); - UNUSED(con); - - PATCH(access_deny); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_access_uri_handler) { plugin_data *p = p_d; int s_len; - size_t k, i; + size_t k; - UNUSED(srv); - if (con->uri.path->used == 0) return HANDLER_GO_ON; - mod_access_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_access_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_access_patch_connection(srv, con, p); s_len = con->uri.path->used - 1; diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c index e789926d..15eaf3b4 100644 --- a/src/mod_accesslog.c +++ b/src/mod_accesslog.c @@ -563,16 +563,23 @@ SIGHUP_FUNC(log_access_cycle) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_accesslog_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_accesslog_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(access_logfile); + PATCH(format); + PATCH(log_access_fd); + PATCH(last_generated_accesslog_ts_ptr); + PATCH(access_logbuffer); + PATCH(ts_accesslog_str); + PATCH(parsed_format); + PATCH(use_syslog); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -598,38 +605,16 @@ static int mod_accesslog_patch_connection(server *srv, connection *con, plugin_d return 0; } - -static int mod_accesslog_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(access_logfile); - PATCH(format); - PATCH(log_access_fd); - PATCH(last_generated_accesslog_ts_ptr); - PATCH(access_logbuffer); - PATCH(ts_accesslog_str); - PATCH(parsed_format); - PATCH(use_syslog); - - return 0; -} #undef PATCH REQUESTDONE_FUNC(log_access_write) { plugin_data *p = p_d; - size_t j, i; + size_t j; int newts = 0; data_string *ds; - mod_accesslog_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_accesslog_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_accesslog_patch_connection(srv, con, p); if (p->conf.access_logbuffer->used == 0) { buffer_copy_string(p->conf.access_logbuffer, ""); diff --git a/src/mod_alias.c b/src/mod_alias.c index b7a4c339..e4869493 100644 --- a/src/mod_alias.c +++ b/src/mod_alias.c @@ -93,16 +93,16 @@ SETDEFAULTS_FUNC(mod_alias_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_alias_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_alias_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(alias); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -119,32 +119,17 @@ static int mod_alias_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_alias_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(alias); - - return 0; -} #undef PATCH PHYSICALPATH_FUNC(mod_alias_physical_handler) { plugin_data *p = p_d; int uri_len, basedir_len; char *uri_ptr; - size_t k, i; + size_t k; if (con->physical.path->used == 0) return HANDLER_GO_ON; - mod_alias_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_alias_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_alias_patch_connection(srv, con, p); /* not to include the tailing slash */ basedir_len = (con->physical.basedir->used - 1) - 1; diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 02ffe468..9f47e4f3 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -1001,16 +1001,16 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer * #define PATCH(x) \ p->conf.x = s->x; -static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(cgi); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -1027,31 +1027,16 @@ static int mod_cgi_patch_connection(server *srv, connection *con, plugin_data *p return 0; } - -static int mod_cgi_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(cgi); - - return 0; -} #undef PATCH URIHANDLER_FUNC(cgi_is_handled) { - size_t k, s_len, i; + size_t k, s_len; plugin_data *p = p_d; buffer *fn = con->physical.path; if (fn->used == 0) return HANDLER_ERROR; - mod_cgi_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_cgi_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_cgi_patch_connection(srv, con, p); s_len = fn->used - 1; diff --git a/src/mod_cml.c b/src/mod_cml.c index 89bfb862..99458107 100644 --- a/src/mod_cml.c +++ b/src/mod_cml.c @@ -135,16 +135,20 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_cml_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_cml_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(ext); +#if defined(HAVE_MEMCACHE_H) + PATCH(mc); +#endif + PATCH(mc_namespace); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -167,20 +171,6 @@ static int mod_cml_patch_connection(server *srv, connection *con, plugin_data *p return 0; } - -static int mod_cml_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(ext); -#if defined(HAVE_MEMCACHE_H) - PATCH(mc); -#endif - PATCH(mc_namespace); - - return 0; -} #undef PATCH @@ -313,17 +303,11 @@ URIHANDLER_FUNC(mod_cml_is_handled) { char *c; buffer *fn = con->physical.path; plugin_data *p = p_d; - size_t i; int ret; if (fn->used == 0) return HANDLER_ERROR; - mod_cml_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_cml_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_cml_patch_connection(srv, con, p); buffer_reset(p->basedir); buffer_reset(p->baseurl); diff --git a/src/mod_compress.c b/src/mod_compress.c index a5ffc673..a0193f5c 100644 --- a/src/mod_compress.c +++ b/src/mod_compress.c @@ -526,16 +526,18 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, #define PATCH(x) \ p->conf.x = s->x; -static int mod_compress_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_compress_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(compress_cache_dir); + PATCH(compress); + PATCH(compress_max_filesize); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -556,18 +558,6 @@ static int mod_compress_patch_connection(server *srv, connection *con, plugin_da return 0; } - -static int mod_compress_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(compress_cache_dir); - PATCH(compress); - PATCH(compress_max_filesize); - - return 0; -} #undef PATCH PHYSICALPATH_FUNC(mod_compress_physical) { @@ -583,12 +573,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) { return HANDLER_GO_ON; } - mod_compress_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_compress_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_compress_patch_connection(srv, con, p); max_fsize = p->conf.compress_max_filesize; diff --git a/src/mod_evhost.c b/src/mod_evhost.c index ca89425f..9f4b5614 100644 --- a/src/mod_evhost.c +++ b/src/mod_evhost.c @@ -220,16 +220,17 @@ static int mod_evhost_parse_host(connection *con,array *host) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_evhost_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_evhost_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(path_pieces); + PATCH(len); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -247,17 +248,6 @@ static int mod_evhost_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_evhost_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(path_pieces); - PATCH(len); - - return 0; -} #undef PATCH @@ -272,12 +262,7 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d) /* not authority set */ if (con->uri.authority->used == 0) return HANDLER_GO_ON; - mod_evhost_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_evhost_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_evhost_patch_connection(srv, con, p); parsed_host = array_init(); diff --git a/src/mod_expire.c b/src/mod_expire.c index 623f4dde..62a18fa3 100644 --- a/src/mod_expire.c +++ b/src/mod_expire.c @@ -249,16 +249,16 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_expire_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_expire_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(expire_url); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -275,31 +275,16 @@ static int mod_expire_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_expire_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(expire_url); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_expire_path_handler) { plugin_data *p = p_d; int s_len; - size_t k, i; + size_t k; if (con->uri.path->used == 0) return HANDLER_GO_ON; - mod_expire_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_expire_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_expire_patch_connection(srv, con, p); s_len = con->uri.path->used - 1; diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 57587dd2..824fdd6d 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -2893,16 +2893,17 @@ static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents) { } #define PATCH(x) \ p->conf.x = s->x; -static int fcgi_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int fcgi_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(exts); + PATCH(debug); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -2921,17 +2922,6 @@ static int fcgi_patch_connection(server *srv, connection *con, plugin_data *p, c return 0; } - -static int fcgi_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(exts); - PATCH(debug); - - return 0; -} #undef PATCH @@ -2940,7 +2930,7 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i size_t s_len; int used = -1; int ndx; - size_t k, i; + size_t k; buffer *fn; fcgi_extension *extension = NULL; @@ -2955,13 +2945,7 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i s_len = fn->used - 1; - /* select the right config */ - fcgi_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - fcgi_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + fcgi_patch_connection(srv, con, p); /* check if extension matches */ for (k = 0; k < p->conf.exts->used; k++) { diff --git a/src/mod_mysql_vhost.c b/src/mod_mysql_vhost.c index 523cc0e2..e6da94b6 100644 --- a/src/mod_mysql_vhost.c +++ b/src/mod_mysql_vhost.c @@ -271,16 +271,20 @@ SERVER_FUNC(mod_mysql_vhost_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_mysql_vhost_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_mysql_vhost_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(mysql_pre); + PATCH(mysql_post); +#ifdef HAVE_MYSQL + PATCH(mysql); +#endif /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -302,19 +306,6 @@ static int mod_mysql_vhost_patch_connection(server *srv, connection *con, plugin return 0; } - -static int mod_mysql_vhost_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - - UNUSED(srv); - UNUSED(con); - - PATCH(mysql_pre); - PATCH(mysql_post); - PATCH(mysql); - - return 0; -} #undef PATCH @@ -332,13 +323,7 @@ CONNECTION_FUNC(mod_mysql_vhost_handle_docroot) { /* no host specified? */ if (!con->uri.authority->used) return HANDLER_GO_ON; - /* apply conditionals */ - mod_mysql_vhost_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_mysql_vhost_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_mysql_vhost_patch_connection(srv, con, p); /* sets up connection data if not done yet */ c = mod_mysql_vhost_connection_data(srv, con, p_d); diff --git a/src/mod_proxy.c b/src/mod_proxy.c index 7775df61..b728b822 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -789,16 +789,17 @@ static handler_t proxy_write_request(server *srv, handler_ctx *hctx) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_proxy_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_proxy_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(extensions); + PATCH(debug); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -819,18 +820,6 @@ static int mod_proxy_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_proxy_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(extensions); - PATCH(debug); - PATCH(balance); - - return 0; -} #undef PATCH SUBREQUEST_FUNC(mod_proxy_handle_subrequest) { @@ -838,17 +827,10 @@ SUBREQUEST_FUNC(mod_proxy_handle_subrequest) { handler_ctx *hctx = con->plugin_ctx[p->id]; data_proxy *host; - size_t i; if (NULL == hctx) return HANDLER_GO_ON; - /* select the right config */ - mod_proxy_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_proxy_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_proxy_patch_connection(srv, con, p); host = hctx->host; @@ -1003,7 +985,7 @@ static handler_t mod_proxy_check_extension(server *srv, connection *con, void *p size_t s_len; unsigned long last_max = ~0L; int ndx = -1; - size_t k, i; + size_t k; buffer *fn; data_array *extension = NULL; size_t path_info_offset; @@ -1011,13 +993,7 @@ static handler_t mod_proxy_check_extension(server *srv, connection *con, void *p /* Possibly, we processed already this request */ if (con->file_started == 1) return HANDLER_GO_ON; - /* select the right config */ - mod_proxy_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_proxy_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_proxy_patch_connection(srv, con, p); fn = con->uri.path; diff --git a/src/mod_redirect.c b/src/mod_redirect.c index 7ad486ac..1627f2ed 100644 --- a/src/mod_redirect.c +++ b/src/mod_redirect.c @@ -134,16 +134,16 @@ SETDEFAULTS_FUNC(mod_redirect_set_defaults) { return HANDLER_GO_ON; } #ifdef HAVE_PCRE_H -static int mod_redirect_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_redirect_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + p->conf.redirect = s->redirect; /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -160,17 +160,6 @@ static int mod_redirect_patch_connection(server *srv, connection *con, plugin_da return 0; } - -static int mod_redirect_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - - UNUSED(srv); - UNUSED(con); - - p->conf.redirect = s->redirect; - - return 0; -} #endif static handler_t mod_redirect_uri_handler(server *srv, connection *con, void *p_data) { #ifdef HAVE_PCRE_H @@ -184,12 +173,7 @@ static handler_t mod_redirect_uri_handler(server *srv, connection *con, void *p_ * */ - mod_redirect_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_redirect_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_redirect_patch_connection(srv, con, p); buffer_copy_string_buffer(p->match_buf, con->request.uri); diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c index 12bef677..bf1b8446 100644 --- a/src/mod_rewrite.c +++ b/src/mod_rewrite.c @@ -266,16 +266,17 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { return HANDLER_GO_ON; } #ifdef HAVE_PCRE_H -static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + p->conf.rewrite = s->rewrite; /* 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]; - plugin_config *s = p->config_storage[i]; + s = p->config_storage[i]; - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + if (buffer_is_equal_string(dc->comp_key, CONST_STR_LEN("HTTPurl"))) continue; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -298,17 +299,6 @@ static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_dat return 0; } - -static int mod_rewrite_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - - UNUSED(srv); - UNUSED(con); - - p->conf.rewrite = s->rewrite; - - return 0; -} #endif URIHANDLER_FUNC(mod_rewrite_con_reset) { plugin_data *p = p_d; @@ -348,12 +338,9 @@ URIHANDLER_FUNC(mod_rewrite_uri_handler) { if (hctx->state == REWRITE_STATE_FINISHED) return HANDLER_GO_ON; } - mod_rewrite_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_rewrite_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_rewrite_patch_connection(srv, con, p); + + if (!p->conf.rewrite) return HANDLER_GO_ON; buffer_copy_string_buffer(p->match_buf, con->request.uri); diff --git a/src/mod_rrdtool.c b/src/mod_rrdtool.c index d6582186..0807844d 100644 --- a/src/mod_rrdtool.c +++ b/src/mod_rrdtool.c @@ -251,16 +251,21 @@ static int mod_rrdtool_create_rrd(server *srv, plugin_data *p, plugin_config *s) #define PATCH(x) \ p->conf.x = s->x; -static int mod_rrd_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_rrd_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(path_rrdtool_bin); + PATCH(path_rrd); + + p->conf.bytes_written_ptr = &(s->bytes_written); + p->conf.bytes_read_ptr = &(s->bytes_read); + p->conf.requests_ptr = &(s->requests); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -282,21 +287,6 @@ static int mod_rrd_patch_connection(server *srv, connection *con, plugin_data *p return 0; } - -static int mod_rrd_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(path_rrdtool_bin); - PATCH(path_rrd); - - p->conf.bytes_written_ptr = &(s->bytes_written); - p->conf.bytes_read_ptr = &(s->bytes_read); - p->conf.requests_ptr = &(s->requests); - - return 0; -} #undef PATCH SETDEFAULTS_FUNC(mod_rrd_set_defaults) { @@ -431,14 +421,8 @@ TRIGGER_FUNC(mod_rrd_trigger) { REQUESTDONE_FUNC(mod_rrd_account) { plugin_data *p = p_d; - size_t i; - mod_rrd_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_rrd_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_rrd_patch_connection(srv, con, p); *(p->conf.requests_ptr) += 1; *(p->conf.bytes_written_ptr) += con->bytes_written; diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 63e0aa21..7f0b579d 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -2592,16 +2592,17 @@ static handler_t scgi_handle_fdevent(void *s, void *ctx, int revents) { } #define PATCH(x) \ p->conf.x = s->x; -static int scgi_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int scgi_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(exts); + PATCH(debug); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -2620,17 +2621,6 @@ static int scgi_patch_connection(server *srv, connection *con, plugin_data *p, c return 0; } - -static int scgi_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(exts); - PATCH(debug); - - return 0; -} #undef PATCH @@ -2639,7 +2629,7 @@ static handler_t scgi_check_extension(server *srv, connection *con, void *p_d, i size_t s_len; int used = -1; int ndx; - size_t k, i; + size_t k; buffer *fn; scgi_extension *extension = NULL; size_t path_info_offset; @@ -2656,12 +2646,7 @@ static handler_t scgi_check_extension(server *srv, connection *con, void *p_d, i s_len = fn->used - 1; /* select the right config */ - scgi_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - scgi_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + scgi_patch_connection(srv, con, p); path_info_offset = 0; diff --git a/src/mod_secure_download.c b/src/mod_secure_download.c index eecc230a..098fa590 100644 --- a/src/mod_secure_download.c +++ b/src/mod_secure_download.c @@ -165,16 +165,19 @@ int is_hex_len(const char *str, size_t len) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_secdownload_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_secdownload_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(secret); + PATCH(doc_root); + PATCH(uri_prefix); + PATCH(timeout); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -197,19 +200,6 @@ static int mod_secdownload_patch_connection(server *srv, connection *con, plugin return 0; } - -static int mod_secdownload_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(secret); - PATCH(doc_root); - PATCH(uri_prefix); - PATCH(timeout); - - return 0; -} #undef PATCH @@ -223,12 +213,7 @@ URIHANDLER_FUNC(mod_secdownload_uri_handler) { if (con->uri.path->used == 0) return HANDLER_GO_ON; - mod_secdownload_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_secdownload_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_secdownload_patch_connection(srv, con, p); if (buffer_is_empty(p->conf.secret)) { log_error_write(srv, __FILE__, __LINE__, "s", diff --git a/src/mod_setenv.c b/src/mod_setenv.c index 07df0a84..ca97a38b 100644 --- a/src/mod_setenv.c +++ b/src/mod_setenv.c @@ -105,16 +105,18 @@ SETDEFAULTS_FUNC(mod_setenv_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_setenv_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_setenv_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(request_header); + PATCH(response_header); + PATCH(environment); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -135,30 +137,13 @@ static int mod_setenv_patch_connection(server *srv, connection *con, plugin_data return 0; } - -static int mod_setenv_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(request_header); - PATCH(response_header); - PATCH(environment); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_setenv_uri_handler) { plugin_data *p = p_d; size_t k, i; - mod_setenv_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_setenv_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_setenv_patch_connection(srv, con, p); for (k = 0; k < p->conf.request_header->used; k++) { data_string *ds = (data_string *)p->conf.request_header->data[k]; diff --git a/src/mod_simple_vhost.c b/src/mod_simple_vhost.c index 260901c5..e3f1c01c 100644 --- a/src/mod_simple_vhost.c +++ b/src/mod_simple_vhost.c @@ -167,16 +167,22 @@ static int build_doc_root(server *srv, connection *con, plugin_data *p, buffer * #define PATCH(x) \ p->conf.x = s->x; -static int mod_simple_vhost_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_simple_vhost_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(server_root); + PATCH(default_host); + PATCH(document_root); + + PATCH(docroot_cache_key); + PATCH(docroot_cache_value); + PATCH(docroot_cache_servername); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -200,27 +206,10 @@ static int mod_simple_vhost_patch_connection(server *srv, connection *con, plugi return 0; } - -static int mod_simple_vhost_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(server_root); - PATCH(default_host); - PATCH(document_root); - - PATCH(docroot_cache_key); - PATCH(docroot_cache_value); - PATCH(docroot_cache_servername); - - return 0; -} #undef PATCH static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_data) { plugin_data *p = p_data; - size_t i; /* * cache the last successfull translation from hostname (authority) to docroot @@ -228,12 +217,7 @@ static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_ * */ - mod_simple_vhost_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_simple_vhost_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_simple_vhost_patch_connection(srv, con, p); if (p->conf.docroot_cache_key->used && con->uri.authority->used && diff --git a/src/mod_skeleton.c b/src/mod_skeleton.c index b5dab829..ca882ef4 100644 --- a/src/mod_skeleton.c +++ b/src/mod_skeleton.c @@ -129,16 +129,16 @@ SETDEFAULTS_FUNC(mod_skeleton_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_skeleton_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_skeleton_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(match); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -155,16 +155,6 @@ static int mod_skeleton_patch_connection(server *srv, connection *con, plugin_da return 0; } - -static int mod_skeleton_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(match); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_skeleton_uri_handler) { @@ -176,12 +166,7 @@ URIHANDLER_FUNC(mod_skeleton_uri_handler) { if (con->uri.path->used == 0) return HANDLER_GO_ON; - mod_skeleton_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_skeleton_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_skeleton_patch_connection(srv, con, p); s_len = con->uri.path->used - 1; diff --git a/src/mod_ssi.c b/src/mod_ssi.c index 131d785b..45201b10 100644 --- a/src/mod_ssi.c +++ b/src/mod_ssi.c @@ -984,16 +984,16 @@ static int mod_ssi_handle_request(server *srv, connection *con, plugin_data *p) #define PATCH(x) \ p->conf.x = s->x; -static int mod_ssi_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_ssi_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(ssi_extension); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -1010,30 +1010,15 @@ static int mod_ssi_patch_connection(server *srv, connection *con, plugin_data *p return 0; } - -static int mod_ssi_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(ssi_extension); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_ssi_physical_path) { plugin_data *p = p_d; - size_t k, i; + size_t k; if (con->physical.path->used == 0) return HANDLER_GO_ON; - mod_ssi_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_ssi_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_ssi_patch_connection(srv, con, p); for (k = 0; k < p->conf.ssi_extension->used; k++) { data_string *ds = (data_string *)p->conf.ssi_extension->data[k]; diff --git a/src/mod_status.c b/src/mod_status.c index 24dc711a..b09c1048 100644 --- a/src/mod_status.c +++ b/src/mod_status.c @@ -501,7 +501,12 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c BUFFER_APPEND_STRING_CONST(b, ""); - buffer_append_string_buffer(b, c->server_name); + if (buffer_is_empty(c->server_name)) { + buffer_append_string_buffer(b, c->uri.authority); + } + else { + buffer_append_string_buffer(b, c->server_name); + } BUFFER_APPEND_STRING_CONST(b, ""); @@ -671,16 +676,17 @@ static handler_t mod_status_handle_server_config(server *srv, connection *con, v #define PATCH(x) \ p->conf.x = s->x; -static int mod_skeleton_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_status_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(status_url); + PATCH(config_url); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -702,29 +708,10 @@ static int mod_skeleton_patch_connection(server *srv, connection *con, plugin_da return 0; } -static int mod_skeleton_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(status_url); - PATCH(config_url); - PATCH(sort); - - return 0; -} -#undef PATCH - static handler_t mod_status_handler(server *srv, connection *con, void *p_d) { plugin_data *p = p_d; - size_t i; - mod_skeleton_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_skeleton_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_status_patch_connection(srv, con, p); if (!buffer_is_empty(p->conf.status_url) && buffer_is_equal(p->conf.status_url, con->uri.path)) { diff --git a/src/mod_trigger_b4_dl.c b/src/mod_trigger_b4_dl.c index 0f9aa28f..d4384790 100644 --- a/src/mod_trigger_b4_dl.c +++ b/src/mod_trigger_b4_dl.c @@ -242,16 +242,22 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + +#if defined(HAVE_GDBM) && defined(HAVE_PCRE_H) + PATCH(db); + PATCH(download_regex); + PATCH(trigger_regex); + PATCH(trigger_timeout); + PATCH(deny_url); +#endif /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -288,25 +294,6 @@ static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plug return 0; } - -static int mod_trigger_b4_dl_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); -#if defined(HAVE_GDBM_H) - PATCH(db); -#endif -#if defined(HAVE_PCRE_H) - PATCH(download_regex); - PATCH(trigger_regex); -#endif - PATCH(trigger_timeout); - PATCH(deny_url); -#if defined(HAVE_MEMCACHE_H) - PATCH(mc); -#endif - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { @@ -322,12 +309,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { if (con->uri.path->used == 0) return HANDLER_GO_ON; - mod_trigger_b4_dl_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_trigger_b4_dl_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_trigger_b4_dl_patch_connection(srv, con, p); if (!p->conf.trigger_regex || !p->conf.download_regex) return HANDLER_GO_ON; diff --git a/src/mod_userdir.c b/src/mod_userdir.c index d098fbc2..b0cf6990 100644 --- a/src/mod_userdir.c +++ b/src/mod_userdir.c @@ -114,16 +114,18 @@ SETDEFAULTS_FUNC(mod_userdir_set_defaults) { #define PATCH(x) \ p->conf.x = s->x; -static int mod_userdir_patch_connection(server *srv, connection *con, plugin_data *p, const char *stage, size_t stage_len) { +static int mod_userdir_patch_connection(server *srv, connection *con, plugin_data *p) { size_t i, j; + plugin_config *s = p->config_storage[0]; + + PATCH(path); + PATCH(exclude_user); + PATCH(include_user); /* 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]; - plugin_config *s = p->config_storage[i]; - - /* not our stage */ - if (!buffer_is_equal_string(dc->comp_key, stage, stage_len)) continue; + s = p->config_storage[i]; /* condition didn't match */ if (!config_check_cond(srv, con, dc)) continue; @@ -144,18 +146,6 @@ static int mod_userdir_patch_connection(server *srv, connection *con, plugin_dat return 0; } - -static int mod_userdir_setup_connection(server *srv, connection *con, plugin_data *p) { - plugin_config *s = p->config_storage[0]; - UNUSED(srv); - UNUSED(con); - - PATCH(path); - PATCH(exclude_user); - PATCH(include_user); - - return 0; -} #undef PATCH URIHANDLER_FUNC(mod_userdir_docroot_handler) { @@ -164,16 +154,10 @@ URIHANDLER_FUNC(mod_userdir_docroot_handler) { size_t k; char *rel_url; struct passwd *pwd; - size_t i; if (con->uri.path->used == 0) return HANDLER_GO_ON; #ifdef HAVE_PWD_H - mod_userdir_setup_connection(srv, con, p); - for (i = 0; i < srv->config_patches->used; i++) { - buffer *patch = srv->config_patches->ptr[i]; - - mod_userdir_patch_connection(srv, con, p, CONST_BUF_LEN(patch)); - } + mod_userdir_patch_connection(srv, con, p); uri_len = con->uri.path->used - 1; diff --git a/src/stream.c b/src/stream.c index bdfcc334..d82a60db 100644 --- a/src/stream.c +++ b/src/stream.c @@ -9,6 +9,9 @@ #include "sys-mmap.h" +#ifndef O_BINARY +# define O_BINARY 0 +#endif int stream_open(stream *f, buffer *fn) { struct stat st;