Browse Source

[core] copy some srv->srvconf into con->conf

(for memory locality and to reduce pointer chasing)
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
33430ce2b0
  1. 19
      src/base.h
  2. 6
      src/configfile.c
  3. 2
      src/connections-glue.c
  4. 11
      src/connections.c
  5. 4
      src/request.c

19
src/base.h

@ -83,6 +83,7 @@ typedef struct {
const buffer *server_tag;
log_error_st *errh;
uint32_t max_request_field_size;
unsigned short max_keep_alive_requests;
unsigned short max_keep_alive_idle;
unsigned short max_read_idle;
@ -106,6 +107,8 @@ typedef struct {
unsigned char log_response_header;
unsigned char log_condition_handling;
unsigned char log_timeouts;
unsigned char log_state_handling;
unsigned char log_request_header_on_error;
unsigned int http_parseopts;
unsigned int max_request_size;
@ -249,12 +252,11 @@ typedef struct {
} buffer_plugin;
typedef struct {
unsigned int max_request_field_size;
unsigned int log_state_handling;
unsigned char log_request_header_on_error;
/*(used sparsely, if at all, after config at startup)*/
uint32_t max_request_field_size;
unsigned char log_state_handling;
unsigned char log_request_header_on_error;
unsigned char http_header_strict;
unsigned char http_host_strict;
unsigned char http_host_normalize;
@ -313,6 +315,7 @@ typedef struct {
struct server {
void *plugin_slots;
array *config_context;
struct fdevents *ev;
int (* network_backend_write)(int fd, chunkqueue *cq, off_t max_bytes, log_error_st *errh);
@ -341,16 +344,14 @@ struct server {
log_error_st *errh;
server_config srvconf;
time_t loadts;
double loadavg[3];
/* config-file */
/* members used at start-up or rarely used */
server_config srvconf;
void *config_data_base;
array *config_context;
/* members used at start-up or rarely used */
server_socket_array srv_sockets;
server_socket_array srv_sockets_inherited;
buffer_plugin plugins;

6
src/configfile.c

@ -969,8 +969,12 @@ static int config_insert(server *srv) {
}
/* (after processing config defaults) */
p->defaults.max_request_field_size = srv->srvconf.max_request_field_size;
p->defaults.log_state_handling = srv->srvconf.log_state_handling;
p->defaults.log_request_header_on_error =
srv->srvconf.log_request_header_on_error;
if (p->defaults.log_request_handling || p->defaults.log_request_header)
srv->srvconf.log_request_header_on_error = 1;
p->defaults.log_request_header_on_error = 1;
return rc;
}

2
src/connections-glue.c

@ -186,7 +186,7 @@ static handler_t connection_handle_read_post_chunked(connection *con, chunkqueue
* potentially received by backend, if in the future
* these trailers are added to request headers)*/
if ((off_t)buffer_string_length(c->mem) - c->offset
< con->srv->srvconf.max_request_field_size) {
< (off_t)con->conf.max_request_field_size) {
break;
}
else {

11
src/connections.c

@ -130,7 +130,7 @@ static int connection_close(connection *con) {
log_perror(con->conf.errh, __FILE__, __LINE__,
"(warning) close: %d", con->fd);
if (srv->srvconf.log_state_handling) {
if (con->conf.log_state_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,
"connection closed for fd %d", con->fd);
}
@ -206,7 +206,7 @@ static void connection_handle_shutdown(connection *con) {
con->close_timeout_ts = log_epoch_secs;
connection_set_state(con, CON_STATE_CLOSE);
if (con->srv->srvconf.log_state_handling) {
if (con->conf.log_state_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,
"shutdown for fd %d", con->fd);
}
@ -792,8 +792,7 @@ static int connection_handle_read_state(connection * const con) {
/* casting to (unsigned short) might truncate, and the hoff[]
* addition might overflow, but max_request_field_size is USHRT_MAX,
* so failure will be detected below */
const unsigned int max_request_field_size =
con->srv->srvconf.max_request_field_size;
const uint32_t max_request_field_size=con->conf.max_request_field_size;
if ((con->header_len ? con->header_len : clen) > max_request_field_size
|| hoff[0] >= sizeof(hoff)/sizeof(hoff[0])-1) {
log_error(con->conf.errh, __FILE__, __LINE__, "%s",
@ -851,7 +850,7 @@ static int connection_handle_read_state(connection * const con) {
con->keep_alive = 0;
con->request.content_length = 0;
if (con->srv->srvconf.log_request_header_on_error) {
if (con->conf.log_request_header_on_error) {
/*(http_request_parse() modifies hdrs only to
* undo line-wrapping in-place using spaces)*/
log_error(con->conf.errh, __FILE__, __LINE__, "request-header:\n%.*s",
@ -1243,7 +1242,7 @@ static int connection_handle_request(connection *con) {
int connection_state_machine(connection *con) {
connection_state_t ostate;
int rc;
const int log_state_handling = con->srv->srvconf.log_state_handling;
const int log_state_handling = con->conf.log_state_handling;
if (log_state_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,

4
src/request.c

@ -348,7 +348,7 @@ static int request_uri_is_valid_char(const unsigned char c) {
__attribute_cold__
__attribute_noinline__
static int http_request_header_line_invalid(connection * const con, const int status, const char * const msg) {
if (con->srv->srvconf.log_request_header_on_error) {
if (con->conf.log_request_header_on_error) {
if (msg) log_error(con->conf.errh, __FILE__, __LINE__, "%s", msg);
}
return status;
@ -357,7 +357,7 @@ static int http_request_header_line_invalid(connection * const con, const int st
__attribute_cold__
__attribute_noinline__
static int http_request_header_char_invalid(connection * const con, const char ch, const char * const msg) {
if (con->srv->srvconf.log_request_header_on_error) {
if (con->conf.log_request_header_on_error) {
if ((unsigned char)ch > 32 && ch != 127) {
log_error(con->conf.errh, __FILE__, __LINE__, "%s ('%c')", msg, ch);
}

Loading…
Cancel
Save