Browse Source

[core] isolate data_config.c, vector.c

isolate data_config.c, vector.c to lighttpd executable, not modules
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
0c64096555
  1. 10
      src/CMakeLists.txt
  2. 10
      src/Makefile.am
  3. 4
      src/SConscript
  4. 43
      src/configfile-glue.c
  5. 9
      src/configfile.h
  6. 20
      src/data_config.c
  7. 8
      src/meson.build

10
src/CMakeLists.txt

@ -641,12 +641,10 @@ set(COMMON_SRC
stat_cache.c plugin.c etag.c array.c
data_string.c data_array.c
data_integer.c algo_sha1.c md5.c
vector.c
fdevent_select.c fdevent_libev.c
fdevent_poll.c fdevent_linux_sysepoll.c
fdevent_solaris_devpoll.c fdevent_solaris_port.c
fdevent_freebsd_kqueue.c
data_config.c
crc32.c
connections-glue.c
configfile-glue.c
@ -684,6 +682,8 @@ add_executable(lighttpd
inet_ntop_cache.c
network.c
network_write.c
data_config.c
vector.c
configfile.c
configparser.c
${COMMON_SRC}
@ -790,12 +790,10 @@ add_executable(test_mod_access
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)
@ -806,12 +804,10 @@ add_executable(test_mod_evhost
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)
@ -822,12 +818,10 @@ add_executable(test_mod_simple_vhost
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)

10
src/Makefile.am

@ -79,12 +79,10 @@ common_src=base64.c buffer.c burl.c log.c \
stat_cache.c plugin.c etag.c array.c \
data_string.c data_array.c \
data_integer.c algo_sha1.c md5.c \
vector.c \
fdevent_select.c fdevent_libev.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
fdevent_solaris_devpoll.c fdevent_solaris_port.c \
fdevent_freebsd_kqueue.c \
data_config.c \
crc32.c \
connections-glue.c \
configfile-glue.c \
@ -101,6 +99,8 @@ src = server.c response.c connections.c \
inet_ntop_cache.c \
network.c \
network_write.c \
data_config.c \
vector.c \
configfile.c configparser.c
lib_LTLIBRARIES =
@ -573,13 +573,13 @@ t_test_configfile_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_keyvalue_SOURCES = t/test_keyvalue.c burl.c buffer.c base64.c array.c data_integer.c data_string.c log.c
t_test_keyvalue_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_access_SOURCES = t/test_mod_access.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_access_SOURCES = t/test_mod_access.c configfile-glue.c buffer.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_mod_access_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c configfile-glue.c buffer.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_mod_evhost_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c configfile-glue.c buffer.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_mod_simple_vhost_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_request_SOURCES = t/test_request.c request.c buffer.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c

4
src/SConscript

@ -61,12 +61,10 @@ common_src = Split("base64.c buffer.c burl.c log.c \
stat_cache.c plugin.c etag.c array.c \
data_string.c data_array.c \
data_integer.c algo_sha1.c md5.c \
vector.c \
fdevent_select.c fdevent_libev.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
fdevent_solaris_devpoll.c fdevent_solaris_port.c \
fdevent_freebsd_kqueue.c \
data_config.c \
crc32.c \
connections-glue.c \
configfile-glue.c \
@ -84,6 +82,8 @@ src = Split("server.c response.c connections.c \
inet_ntop_cache.c \
network.c \
network_write.c \
data_config.c \
vector.c \
configfile.c configparser.c")
lemon = env.Program('lemon', 'lemon.c', LIBS = GatherLibs(env))

43
src/configfile-glue.c

@ -28,7 +28,7 @@
/* handle global options */
/* parse config array */
int config_insert_values_internal(server *srv, array *ca, const config_values_t cv[], config_scope_type_t scope) {
int config_insert_values_internal(server *srv, const array *ca, const config_values_t cv[], config_scope_type_t scope) {
size_t i;
const data_unset *du;
@ -187,7 +187,7 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t
return 0;
}
int config_insert_values_global(server *srv, array *ca, const config_values_t cv[], config_scope_type_t scope) {
int config_insert_values_global(server *srv, const array *ca, const config_values_t cv[], config_scope_type_t scope) {
size_t i;
const data_unset *du;
@ -264,9 +264,11 @@ static int config_addrbuf_eq_remote_ip_mask(server *srv, buffer *string, char *n
return config_addrstr_eq_remote_ip_mask(srv, addrstr, nm_bits, rmt);
}
static cond_result_t config_check_cond_cached(server *srv, connection *con, data_config *dc);
static int data_config_pcre_exec(const data_config *dc, cond_cache_t *cache, buffer *b);
static cond_result_t config_check_cond_nocache(server *srv, connection *con, data_config *dc) {
static cond_result_t config_check_cond_cached(server *srv, connection *con, const data_config *dc);
static cond_result_t config_check_cond_nocache(server *srv, connection *con, const data_config *dc) {
buffer *l;
server_socket *srv_sock = con->srv_socket;
cond_cache_t *cache = &con->cond_cache[dc->context_ndx];
@ -474,7 +476,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat
return COND_RESULT_FALSE;
}
static cond_result_t config_check_cond_cached(server *srv, connection *con, data_config *dc) {
static cond_result_t config_check_cond_cached(server *srv, connection *con, const data_config *dc) {
cond_cache_t *caches = con->cond_cache;
if (COND_RESULT_UNSET == caches[dc->context_ndx].result) {
@ -508,7 +510,7 @@ static cond_result_t config_check_cond_cached(server *srv, connection *con, data
/* if we reset the cache result for a node, we also need to clear all
* child nodes and else-branches*/
static void config_cond_clear_node(server *srv, connection *con, data_config *dc) {
static void config_cond_clear_node(server *srv, connection *con, const data_config *dc) {
/* if a node is "unset" all children are unset too */
if (con->cond_cache[dc->context_ndx].result != COND_RESULT_UNSET) {
size_t i;
@ -527,7 +529,7 @@ static void config_cond_clear_node(server *srv, connection *con, data_config *dc
con->cond_cache[dc->context_ndx].result = COND_RESULT_UNSET;
for (i = 0; i < dc->children.used; ++i) {
data_config *dc_child = dc->children.data[i];
const data_config *dc_child = dc->children.data[i];
if (NULL == dc_child->prev) {
/* only call for first node in if-else chain */
config_cond_clear_node(srv, con, dc_child);
@ -544,7 +546,7 @@ static void config_cond_clear_node(server *srv, connection *con, data_config *dc
*/
void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item) {
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
data_config *dc = (data_config *)srv->config_context->data[i];
const data_config *dc = (data_config *)srv->config_context->data[i];
if (item == dc->comp) {
/* clear local_result */
@ -572,9 +574,32 @@ void config_cond_cache_reset(server *srv, connection *con) {
}
}
int config_check_cond(server *srv, connection *con, data_config *dc) {
int config_check_cond(server *srv, connection *con, const data_config *dc) {
if (con->conf.log_condition_handling) {
log_error_write(srv, __FILE__, __LINE__, "s", "=== start of condition block ===");
}
return (config_check_cond_cached(srv, con, dc) == COND_RESULT_TRUE);
}
#ifdef HAVE_PCRE_H
#include <pcre.h>
#endif
static int data_config_pcre_exec(const data_config *dc, cond_cache_t *cache, buffer *b) {
#ifdef HAVE_PCRE_H
#ifndef elementsof
#define elementsof(x) (sizeof(x) / sizeof(x[0]))
#endif
cache->patterncount =
pcre_exec(dc->regex, dc->regex_study, CONST_BUF_LEN(b), 0, 0,
cache->matches, elementsof(cache->matches));
if (cache->patterncount > 0)
cache->comp_value = b; /* holds pointer to b (!) for pattern subst */
return cache->patterncount;
#else
UNUSED(dc);
UNUSED(cache);
UNUSED(b);
return 0;
#endif
}

9
src/configfile.h

@ -86,8 +86,7 @@ data_config *data_config_init(void);
__attribute_cold__
int data_config_pcre_compile(data_config *dc);
int data_config_pcre_exec(data_config *dc, struct cond_cache_t *cache, buffer *b);
/*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/
typedef struct {
server *srv;
@ -150,11 +149,11 @@ typedef struct {
} config_values_t;
__attribute_cold__
int config_insert_values_global(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
int config_insert_values_global(server *srv, const array *ca, const config_values_t *cv, config_scope_type_t scope);
__attribute_cold__
int config_insert_values_internal(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
int config_insert_values_internal(server *srv, const array *ca, const config_values_t *cv, config_scope_type_t scope);
int config_check_cond(server *srv, connection *con, data_config *dc);
int config_check_cond(server *srv, connection *con, const data_config *dc);
#endif

20
src/data_config.c

@ -1,6 +1,5 @@
#include "first.h"
#include "base.h" /* (cond_cache_t) */
#include "array.h"
#include "configfile.h"
@ -193,22 +192,3 @@ int data_config_pcre_compile(data_config *dc) {
return 0;
#endif
}
int data_config_pcre_exec(data_config *dc, cond_cache_t *cache, buffer *b) {
#ifdef HAVE_PCRE_H
#ifndef elementsof
#define elementsof(x) (sizeof(x) / sizeof(x[0]))
#endif
cache->patterncount =
pcre_exec(dc->regex, dc->regex_study, CONST_BUF_LEN(b), 0, 0,
cache->matches, elementsof(cache->matches));
if (cache->patterncount > 0)
cache->comp_value = b; /* holds pointer to b (!) for pattern subst */
return cache->patterncount;
#else
UNUSED(dc);
UNUSED(cache);
UNUSED(b);
return 0;
#endif
}

8
src/meson.build

@ -584,7 +584,6 @@ common_src = [
'connections-glue.c',
'crc32.c',
'data_array.c',
'data_config.c',
'data_integer.c',
'data_string.c',
'etag.c',
@ -622,6 +621,7 @@ endif
main_src = [
'configfile.c',
'connections.c',
'data_config.c',
'inet_ntop_cache.c',
'network_write.c',
'network.c',
@ -788,12 +788,10 @@ test('test_mod_access', executable('test_mod_access',
'configfile-glue.c',
'buffer.c',
'array.c',
'data_config.c',
'data_integer.c',
'data_string.c',
'http_header.c',
'http_kv.c',
'vector.c',
'log.c',
'sock_addr.c',
],
@ -807,12 +805,10 @@ test('test_mod_evhost', executable('test_mod_evhost',
'configfile-glue.c',
'buffer.c',
'array.c',
'data_config.c',
'data_integer.c',
'data_string.c',
'http_header.c',
'http_kv.c',
'vector.c',
'log.c',
'sock_addr.c',
],
@ -826,12 +822,10 @@ test('test_mod_simple_vhost', executable('test_mod_simple_vhost',
'configfile-glue.c',
'buffer.c',
'array.c',
'data_config.c',
'data_integer.c',
'data_string.c',
'http_header.c',
'http_kv.c',
'vector.c',
'log.c',
'sock_addr.c',
],

Loading…
Cancel
Save