[core] treat con->conditional_is_valid as bitfield
This commit is contained in:
parent
0c64096555
commit
a7a721ab43
|
@ -267,6 +267,7 @@ struct connection {
|
|||
void **plugin_ctx; /* plugin connection specific config */
|
||||
|
||||
specific_config conf; /* global connection specific config */
|
||||
uint32_t conditional_is_valid;
|
||||
cond_cache_t *cond_cache;
|
||||
|
||||
const buffer *server_name;
|
||||
|
@ -283,8 +284,6 @@ struct connection {
|
|||
|
||||
/* etag handling */
|
||||
etag_flags_t etag_flags;
|
||||
|
||||
int8_t conditional_is_valid[16]; /* MUST be >= COMP_LAST_ELEMENT] */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -322,7 +322,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, con
|
|||
}
|
||||
}
|
||||
|
||||
if (!con->conditional_is_valid[dc->comp]) {
|
||||
if (!(con->conditional_is_valid & (1 << dc->comp))) {
|
||||
if (con->conf.log_condition_handling) {
|
||||
log_error_write(srv, __FILE__, __LINE__, "dss",
|
||||
dc->comp,
|
||||
|
@ -561,16 +561,14 @@ void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item)
|
|||
* reset the config cache to its initial state at connection start
|
||||
*/
|
||||
void config_cond_cache_reset(server *srv, connection *con) {
|
||||
cond_cache_t * const cond_cache = con->cond_cache;
|
||||
con->conditional_is_valid = 0;
|
||||
/* resetting all entries; no need to follow children as in config_cond_cache_reset_item */
|
||||
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
|
||||
con->cond_cache[i].result = COND_RESULT_UNSET;
|
||||
con->cond_cache[i].local_result = COND_RESULT_UNSET;
|
||||
con->cond_cache[i].patterncount = 0;
|
||||
con->cond_cache[i].comp_value = NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < COMP_LAST_ELEMENT; ++i) {
|
||||
con->conditional_is_valid[i] = 0;
|
||||
for (uint32_t i = 1, used = srv->config_context->used; i < used; ++i) {
|
||||
cond_cache[i].result = COND_RESULT_UNSET;
|
||||
cond_cache[i].local_result = COND_RESULT_UNSET;
|
||||
cond_cache[i].patterncount = 0;
|
||||
cond_cache[i].comp_value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1544,8 +1544,6 @@ int config_set_defaults(server *srv) {
|
|||
specific_config *s = srv->config_storage[0];
|
||||
struct stat st1, st2;
|
||||
|
||||
force_assert(sizeof(((connection *)0)->conditional_is_valid) >= COMP_LAST_ELEMENT);
|
||||
|
||||
if (0 != fdevent_config(srv)) return -1;
|
||||
|
||||
if (!buffer_string_is_empty(srv->srvconf.changeroot)) {
|
||||
|
|
|
@ -1118,8 +1118,8 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
|
|||
con->is_ssl_sock = srv_socket->is_ssl;
|
||||
|
||||
config_cond_cache_reset(srv, con);
|
||||
con->conditional_is_valid[COMP_SERVER_SOCKET] = 1;
|
||||
con->conditional_is_valid[COMP_HTTP_REMOTE_IP] = 1;
|
||||
con->conditional_is_valid |= (1 << COMP_SERVER_SOCKET)
|
||||
| (1 << COMP_HTTP_REMOTE_IP);
|
||||
|
||||
buffer_copy_string_len(con->proto, CONST_STR_LEN("http"));
|
||||
if (HANDLER_GO_ON != plugins_call_handle_connection_accept(srv, con)) {
|
||||
|
|
|
@ -347,8 +347,8 @@ mod_openssl_SNI (SSL *ssl, server *srv, handler_ctx *hctx, const char *servernam
|
|||
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
#endif
|
||||
|
||||
con->conditional_is_valid[COMP_HTTP_SCHEME] = 1;
|
||||
con->conditional_is_valid[COMP_HTTP_HOST] = 1;
|
||||
con->conditional_is_valid |= (1 << COMP_HTTP_SCHEME)
|
||||
| (1 << COMP_HTTP_HOST);
|
||||
mod_openssl_patch_connection(srv, con, hctx);
|
||||
/* reset COMP_HTTP_HOST so that conditions re-run after request hdrs read */
|
||||
/*(done in response.c:config_cond_cache_reset() after request hdrs read)*/
|
||||
|
|
|
@ -427,14 +427,14 @@ handler_t http_response_prepare(server *srv, connection *con) {
|
|||
}
|
||||
}
|
||||
|
||||
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_REQUEST_METHOD] = 1; /* REQUEST_METHOD */
|
||||
con->conditional_is_valid[COMP_HTTP_URL] = 1; /* HTTPurl */
|
||||
con->conditional_is_valid[COMP_HTTP_QUERY_STRING] = 1; /* HTTPqs */
|
||||
con->conditional_is_valid[COMP_HTTP_REQUEST_HEADER] = 1; /* HTTP request header */
|
||||
con->conditional_is_valid |= (1 << COMP_SERVER_SOCKET)
|
||||
| (1 << COMP_HTTP_SCHEME)
|
||||
| (1 << COMP_HTTP_HOST)
|
||||
| (1 << COMP_HTTP_REMOTE_IP)
|
||||
| (1 << COMP_HTTP_REQUEST_METHOD)
|
||||
| (1 << COMP_HTTP_URL)
|
||||
| (1 << COMP_HTTP_QUERY_STRING)
|
||||
| (1 << COMP_HTTP_REQUEST_HEADER);
|
||||
config_patch_connection(srv, con);
|
||||
|
||||
/* do we have to downgrade to 1.0 ? */
|
||||
|
|
Loading…
Reference in New Issue