[core] (const buffer *) for con->server_name

use con->server_name_buf when modules set server_name (e.g from db)
personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent 5d13b40824
commit 0ce30f8c22
  1. 3
      src/base.h
  2. 5
      src/configfile.c
  3. 6
      src/connections.c
  4. 3
      src/mod_mysql_vhost.c
  5. 9
      src/mod_simple_vhost.c
  6. 3
      src/mod_vhostdb.c
  7. 2
      src/response.c

@ -264,8 +264,9 @@ struct connection {
specific_config conf; /* global connection specific config */
cond_cache_t *cond_cache;
buffer *server_name;
const buffer *server_name;
buffer *proto;
buffer *server_name_buf;
/* error-handler */
int error_handler_saved_status;

@ -695,7 +695,6 @@ int config_setup_connection(server *srv, connection *con) {
PATCH(global_bytes_per_second_cnt);
con->conf.global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
buffer_copy_buffer(con->server_name, s->server_name);
PATCH(log_request_header);
PATCH(log_response_header);
@ -715,6 +714,8 @@ int config_setup_connection(server *srv, connection *con) {
PATCH(etag_use_mtime);
PATCH(etag_use_size);
con->server_name = s->server_name;
return 0;
}
@ -768,7 +769,7 @@ int config_patch_connection(server *srv, connection *con) {
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.follow-symlink"))) {
PATCH(follow_symlink);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.name"))) {
buffer_copy_buffer(con->server_name, s->server_name);
PATCH(server_name);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.tag"))) {
PATCH(server_tag);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.stream-request-body"))) {

@ -566,7 +566,7 @@ static connection *connection_init(server *srv) {
CLEAN(physical.rel_path);
CLEAN(physical.etag);
CLEAN(server_name);
CLEAN(server_name_buf);
CLEAN(proto);
CLEAN(dst_addr_buf);
@ -626,7 +626,7 @@ void connections_free(server *srv) {
CLEAN(physical.etag);
CLEAN(physical.rel_path);
CLEAN(server_name);
CLEAN(server_name_buf);
CLEAN(proto);
CLEAN(dst_addr_buf);
#undef CLEAN
@ -672,7 +672,7 @@ static int connection_reset(server *srv, connection *con) {
buffer_clear(con->uri.scheme);
/*buffer_clear(con->proto);*//* set to default in connection_accepted() */
/*buffer_clear(con->uri.authority);*/
buffer_clear(con->server_name);
/*buffer_clear(con->server_name_buf);*//* reset when used */
con->request.http_host = NULL;
con->request.content_length = 0;

@ -348,7 +348,8 @@ CONNECTION_FUNC(mod_mysql_vhost_handle_docroot) {
/* fix virtual server and docroot */
GO_ON:
buffer_copy_buffer(con->server_name, c->server_name);
con->server_name = con->server_name_buf;
buffer_copy_buffer(con->server_name_buf, c->server_name);
buffer_copy_buffer(con->physical.doc_root, c->document_root);
return HANDLER_GO_ON;

@ -239,7 +239,8 @@ static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_
!buffer_string_is_empty(con->uri.authority) &&
buffer_is_equal(p->conf.docroot_cache_key, con->uri.authority)) {
/* cache hit */
buffer_copy_buffer(con->server_name, p->conf.docroot_cache_servername);
con->server_name = con->server_name_buf;
buffer_copy_buffer(con->server_name_buf, p->conf.docroot_cache_servername);
buffer_copy_buffer(con->physical.doc_root, p->conf.docroot_cache_value);
} else {
/* build document-root */
@ -250,7 +251,8 @@ static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_
p->doc_root,
p->conf.default_host)) {
/* default host worked */
buffer_copy_buffer(con->server_name, p->conf.default_host);
con->server_name = con->server_name_buf;
buffer_copy_buffer(con->server_name_buf, p->conf.default_host);
buffer_copy_buffer(con->physical.doc_root, p->doc_root);
/* do not cache default host */
}
@ -258,7 +260,8 @@ static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_
}
/* found host */
buffer_copy_buffer(con->server_name, con->uri.authority);
con->server_name = con->server_name_buf;
buffer_copy_buffer(con->server_name_buf, con->uri.authority);
buffer_copy_buffer(con->physical.doc_root, p->doc_root);
/* copy to cache */

@ -166,7 +166,8 @@ static handler_t mod_vhostdb_error_500 (connection *con)
static handler_t mod_vhostdb_found (connection *con, vhostdb_entry *ve)
{
/* fix virtual server and docroot */
buffer_copy_buffer(con->server_name, ve->server_name);
con->server_name = con->server_name_buf;
buffer_copy_buffer(con->server_name_buf, ve->server_name);
buffer_copy_buffer(con->physical.doc_root, ve->document_root);
return HANDLER_GO_ON;
}

@ -626,7 +626,7 @@ handler_t http_response_prepare(server *srv, connection *con) {
/* the docroot plugins might set the servername, if they don't we take http-host */
if (buffer_string_is_empty(con->server_name)) {
buffer_copy_buffer(con->server_name, con->uri.authority);
con->server_name = con->uri.authority;
}
/**

Loading…
Cancel
Save