kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 4010bdd58dcb23b01a7835f4ce68265aa1c5997d
parent b3f65ae13f7b535ae1ec7e1e4c408cc04b5ced09
Author: Joris Vink <joris@coders.se>
Date:   Mon,  4 Aug 2014 19:54:32 +0200

Remove kore_cb and its related settings.

After revisiting why this exists in Kore I decided it
does not belong in this platform and instead of letting
it sit there staring at me I rather just kill it.

Diffstat:
conf/kore.conf.example | 9---------
includes/kore.h | 4----
src/config.c | 67-------------------------------------------------------------------
src/kore.c | 15---------------
src/module.c | 12------------
src/worker.c | 11+----------
6 files changed, 1 insertion(+), 117 deletions(-)

diff --git a/conf/kore.conf.example b/conf/kore.conf.example @@ -23,15 +23,6 @@ workers 4 # Store the main process its pid in this file. #pidfile /var/run/kore.pid -# You can define a callback Kore calls from its parent process or -# workers everytime the kore_cb_interval timer (in milliseconds) is reached. -# -# NOTE: Remember that the parent process runs as root and is not chroot(). -# NOTE: If you want the cb to run on a worker, be sure to set kore_cb_worker. -#kore_cb my_callback -#kore_cb_interval 1000 -#kore_cb_worker 3 - # HTTP specific settings. # http_header_max Maximum size of HTTP headers (in bytes). # diff --git a/includes/kore.h b/includes/kore.h @@ -308,21 +308,17 @@ extern char *chroot_path; extern char *runas_user; extern char *kore_pidfile; extern char *config_file; -extern char *kore_cb_name; extern char *kore_ssl_cipher_list; extern DH *ssl_dhparam; extern int ssl_no_compression; -extern int kore_cb_worker; extern u_int8_t nlisteners; extern u_int64_t spdy_idle_time; extern u_int16_t cpu_count; extern u_int8_t worker_count; -extern u_int64_t kore_cb_interval; extern u_int32_t worker_rlimit_nofiles; extern u_int32_t worker_max_connections; extern u_int32_t worker_active_connections; -extern void (*kore_cb)(void); extern struct listener_head listeners; extern struct kore_worker *worker; diff --git a/src/config.c b/src/config.c @@ -48,9 +48,6 @@ static int configure_ssl_cipher(char **); static int configure_ssl_dhparam(char **); static int configure_ssl_no_compression(char **); static int configure_spdy_idle_time(char **); -static int configure_kore_cb(char **); -static int configure_kore_cb_interval(char **); -static int configure_kore_cb_worker(char **); static int configure_http_header_max(char **); static int configure_http_postbody_max(char **); static int configure_http_hsts_enable(char **); @@ -96,9 +93,6 @@ static struct { { "certfile", configure_certfile }, { "certkey", configure_certkey }, { "require_client_cert", configure_require_client_cert }, - { "kore_cb", configure_kore_cb }, - { "kore_cb_worker", configure_kore_cb_worker }, - { "kore_cb_interval", configure_kore_cb_interval }, { "http_header_max", configure_http_header_max }, { "http_postbody_max", configure_http_postbody_max }, { "http_hsts_enable", configure_http_hsts_enable }, @@ -132,8 +126,6 @@ kore_parse_config(void) if (!kore_module_loaded()) fatal("no site module was loaded"); - if (kore_cb_name != NULL && kore_cb == NULL) - fatal("no '%s' symbol found for kore_cb", kore_cb_name); if (LIST_EMPTY(&listeners)) fatal("no listeners defined"); @@ -571,65 +563,6 @@ configure_rlimit_nofiles(char **argv) } static int -configure_kore_cb(char **argv) -{ - if (argv[1] == NULL) - return (KORE_RESULT_ERROR); - - if (kore_cb_name != NULL) { - kore_debug("kore_cb was already set"); - return (KORE_RESULT_ERROR); - } - - kore_cb_name = kore_strdup(argv[1]); - return (KORE_RESULT_OK); -} - -static int -configure_kore_cb_interval(char **argv) -{ - int err; - - if (argv[1] == NULL) - return (KORE_RESULT_ERROR); - - if (kore_cb_interval != 0) { - kore_debug("kore_cb_interval already given"); - return (KORE_RESULT_ERROR); - } - - kore_cb_interval = kore_strtonum(argv[1], 10, 1, LLONG_MAX, &err); - if (err != KORE_RESULT_OK) { - printf("invalid value for kore_cb_interval: %s\n", argv[1]); - return (KORE_RESULT_ERROR); - } - - return (KORE_RESULT_OK); -} - -static int -configure_kore_cb_worker(char **argv) -{ - int err; - - if (argv[1] == NULL) - return (KORE_RESULT_ERROR); - - if (kore_cb_worker != -1) { - kore_debug("kore_cb_worker already set"); - return (KORE_RESULT_ERROR); - } - - kore_cb_worker = kore_strtonum(argv[1], 10, 0, worker_count, &err); - if (err != KORE_RESULT_OK) { - printf("invalid value for kore_cb_worker: %s\n", argv[1]); - return (KORE_RESULT_ERROR); - } - - return (KORE_RESULT_OK); -} - -static int configure_http_header_max(char **argv) { int err; diff --git a/src/kore.c b/src/kore.c @@ -34,9 +34,6 @@ int skip_chroot = 0; u_int8_t worker_count = 0; char *runas_user = NULL; char *chroot_path = NULL; -int kore_cb_worker = -1; -u_int64_t kore_cb_interval = 0; -void (*kore_cb)(void) = NULL; char *kore_pidfile = KORE_PIDFILE_DEFAULT; char *kore_ssl_cipher_list = KORE_DEFAULT_CIPHER_LIST; @@ -298,7 +295,6 @@ static void kore_server_start(void) { int quit; - u_int64_t now, last_cb_run; kore_mem_free(runas_user); @@ -321,9 +317,6 @@ kore_server_start(void) kore_worker_init(); quit = 0; - now = kore_time_ms(); - last_cb_run = now; - while (quit != 1) { if (sig_recv != 0) { switch (sig_recv) { @@ -348,14 +341,6 @@ kore_server_start(void) if (!kore_accesslog_wait()) break; - if (kore_cb != NULL && kore_cb_worker == -1) { - now = kore_time_ms(); - if ((now - last_cb_run) >= kore_cb_interval) { - kore_cb(); - last_cb_run = now; - } - } - kore_worker_wait(0); } } diff --git a/src/module.c b/src/module.c @@ -21,7 +21,6 @@ #include "kore.h" static TAILQ_HEAD(, kore_module) modules; -char *kore_cb_name = NULL; void kore_module_init(void) @@ -58,9 +57,6 @@ kore_module_load(const char *path, const char *onload) fatal("%s: onload '%s' not present", path, onload); } - if (kore_cb_name != NULL && kore_cb == NULL) - kore_cb = dlsym(module->handle, kore_cb_name); - TAILQ_INSERT_TAIL(&modules, module, list); } @@ -85,8 +81,6 @@ kore_module_reload(int cbs) struct kore_module_handle *hdlr; struct kore_module *module; - kore_cb = NULL; - TAILQ_FOREACH(module, &modules, list) { if (stat(module->path, &st) == -1) { kore_log(LOG_NOTICE, "stat(%s): %s, skipping reload", @@ -119,15 +113,9 @@ kore_module_reload(int cbs) module->ocb(KORE_MODULE_LOAD); } - if (kore_cb_name != NULL && kore_cb == NULL) - kore_cb = dlsym(module->handle, kore_cb_name); - kore_log(LOG_NOTICE, "reloaded '%s' module", module->path); } - if (kore_cb_name != NULL && kore_cb == NULL) - fatal("no kore_cb %s found in loaded modules", kore_cb_name); - TAILQ_FOREACH(dom, &domains, list) { TAILQ_FOREACH(hdlr, &(dom->handlers), list) { hdlr->addr = kore_module_getsym(hdlr->func); diff --git a/src/worker.c b/src/worker.c @@ -180,7 +180,7 @@ kore_worker_entry(struct kore_worker *kw) char buf[16]; struct connection *c, *cnext; int quit, had_lock; - u_int64_t now, idle_check, last_cb_run, timer; + u_int64_t now, idle_check, timer; worker = kw; @@ -237,7 +237,6 @@ kore_worker_entry(struct kore_worker *kw) now = idle_check = 0; kore_platform_event_init(); kore_accesslog_worker_init(); - last_cb_run = kore_time_ms(); #if defined(KORE_USE_PGSQL) kore_pgsql_init(); @@ -296,14 +295,6 @@ kore_worker_entry(struct kore_worker *kw) } } - if (kore_cb != NULL && kore_cb_worker != -1 && - kore_cb_worker == worker->id) { - if ((now - last_cb_run) >= kore_cb_interval) { - kore_cb(); - last_cb_run = now; - } - } - for (c = TAILQ_FIRST(&disconnected); c != NULL; c = cnext) { cnext = TAILQ_NEXT(c, list); TAILQ_REMOVE(&disconnected, c, list);