Browse Source

[core] request_config_reset()

move configfile.c:config_reset_config()
  to reqpool.c:request_config_reset()
master
Glenn Strauss 6 months ago
parent
commit
d5366c0aee
  1. 8
      src/configfile.c
  2. 3
      src/connections.c
  3. 2
      src/h2.c
  4. 2
      src/plugin_config.h
  5. 23
      src/reqpool.c
  6. 7
      src/reqpool.h
  7. 2
      src/request.h
  8. 3
      src/response.c

8
src/configfile.c

@ -12,6 +12,7 @@
#include "configparser.h"
#include "configfile.h"
#include "plugin.h"
#include "reqpool.h"
#include "stat_cache.h"
#include "sys-crypto.h"
@ -203,7 +204,7 @@ static void config_merge_config(request_config * const pconf, const config_plugi
void config_patch_config(request_st * const r) {
config_data_base * const p = r->con->config_data_base;
/* performed by config_reset_config() */
/* performed by request_config_reset() */
/*memcpy(&r->conf, &p->defaults, sizeof(request_config));*/
for (int i = 1, used = p->nconfig; i < used; ++i) {
@ -212,11 +213,13 @@ void config_patch_config(request_st * const r) {
}
}
#if 0 /*(moved to reqpool.c:request_config_reset())*/
void config_reset_config(request_st * const r) {
/* initialize request_config (r->conf) from top-level request_config */
config_data_base * const p = r->con->config_data_base;
memcpy(&r->conf, &p->defaults, sizeof(request_config));
}
#endif
static void config_burl_normalize_cond (server * const srv) {
buffer * const tb = srv->tmp_buf;
@ -1156,6 +1159,8 @@ static int config_insert(server *srv) {
if (p->defaults.log_request_handling || p->defaults.log_request_header)
p->defaults.log_request_header_on_error = 1;
request_config_set_defaults(&p->defaults);
return rc;
}
@ -1382,6 +1387,7 @@ void config_print(server *srv) {
}
void config_free(server *srv) {
/*request_config_set_defaults(NULL);*//*(not necessary)*/
config_free_config(srv->config_data_base);
array_free(srv->config_context);

3
src/connections.c

@ -230,7 +230,6 @@ static void connection_handle_response_end_state(request_st * const r, connectio
if (r->keep_alive > 0) {
request_reset(r);
config_reset_config(r);
con->is_readable = 1; /* potentially trigger optimistic read */
/*(accounting used by mod_accesslog for HTTP/1.0 and HTTP/1.1)*/
r->bytes_read_ckpt = con->bytes_read;
@ -545,7 +544,6 @@ static connection *connection_init(server *srv) {
request_st * const r = &con->request;
request_init_data(r, con, srv);
config_reset_config(r);
con->write_queue = &r->write_queue;
con->read_queue = &r->read_queue;
@ -584,7 +582,6 @@ void connections_free(server *srv) {
static void connection_reset(connection *con) {
request_st * const r = &con->request;
request_reset(r);
config_reset_config(r);
r->bytes_read_ckpt = 0;
r->bytes_written_ckpt = 0;
con->is_readable = 1;

2
src/h2.c

@ -2508,7 +2508,7 @@ h2_init_stream (request_st * const h2r, connection * const con)
if (used > 1) /*(save 128b per con if no conditions)*/
memcpy(r->cond_match, h2r->cond_match, used * sizeof(cond_match_t));
#endif
/*(see config_reset_config() and request_reset_ex())*/
/*(see request_config_reset() and request_reset_ex())*/
r->server_name = h2r->server_name;
memcpy(&r->conf, &h2r->conf, sizeof(request_config));

2
src/plugin_config.h

@ -78,7 +78,7 @@ void config_log_error_close(server *srv);
void config_reset_config_bytes_sec(void *p);
void config_reset_config(request_st *r);
/*void config_reset_config(request_st *r);*//* moved to request_config_reset()*/
void config_patch_config(request_st *r);
void config_cond_cache_reset(request_st *r);

23
src/reqpool.c

@ -8,6 +8,7 @@
#include "reqpool.h"
#include <stdlib.h>
#include <string.h>
#include "base.h"
#include "buffer.h"
@ -18,6 +19,24 @@
#include "response.h"
static const request_config *request_config_defaults;
void
request_config_set_defaults (const request_config *config_defaults)
{
request_config_defaults = config_defaults;
}
__attribute_noinline__
void
request_config_reset (request_st * const r)
{
memcpy(&r->conf, request_config_defaults, sizeof(request_config));
}
void
request_init_data (request_st * const r, connection * const con, server * const srv)
{
@ -48,6 +67,8 @@ request_init_data (request_st * const r, connection * const con, server * const
force_assert(NULL != r->cond_match);
}
#endif
request_config_reset(r);
}
@ -120,6 +141,8 @@ request_reset (request_st * const r)
/* The cond_cache gets reset in response.c */
/* config_cond_cache_reset(r); */
request_config_reset(r);
}

7
src/reqpool.h

@ -4,6 +4,13 @@
#include "base_decls.h"
struct request_config; /* declaration */
__attribute_cold__
void request_config_set_defaults (const struct request_config *config_defaults);
void request_config_reset (request_st * const r);
void request_init_data (request_st *r, connection *con, server *srv);
void request_reset (request_st *r);
void request_reset_ex (request_st *r);

2
src/request.h

@ -16,7 +16,7 @@ struct cond_cache_t; /* declaration */
struct cond_match_t; /* declaration */
struct stat_cache_entry;/* declaration */
typedef struct {
typedef struct request_config {
unsigned int http_parseopts;
uint32_t max_request_field_size;
const array *mimetypes;

3
src/response.c

@ -2,6 +2,7 @@
#include "response.h"
#include "request.h"
#include "reqpool.h"
#include "base.h"
#include "fdevent.h"
#include "http_header.h"
@ -619,7 +620,7 @@ static handler_t http_response_comeback (request_st * const r)
if (NULL != r->handler_module || !buffer_is_unset(&r->physical.path))
return HANDLER_GO_ON;
config_reset_config(r);
request_config_reset(r);
if (__builtin_expect( (r->http_host != NULL), 1)) {
buffer_copy_buffer(&r->uri.authority, r->http_host);

Loading…
Cancel
Save