kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 3023ca0e577e8c5826f1a8babc144418fdcce8c4
parent dcb5fd842fe96a9843540df5bc2a156cb66ec17b
Author: Joris Vink <joris@coders.se>
Date:   Thu, 26 Jan 2017 13:13:23 +0100

Allow single binaries to load modules again.

Diffstat:
src/config.c | 10++++------
src/module.c | 29+++++++++++++----------------
2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -41,9 +41,9 @@ /* XXX - This is becoming a clusterfuck. Fix it. */ -#if !defined(KORE_SINGLE_BINARY) static int configure_load(char *); -#else + +#if defined(KORE_SINGLE_BINARY) static FILE *config_file_write(void); extern u_int8_t asset_builtin_kore_conf[]; extern u_int32_t asset_len_builtin_kore_conf; @@ -116,9 +116,7 @@ static struct { } config_names[] = { { "include", configure_include }, { "bind", configure_bind }, -#if !defined(KORE_SINGLE_BINARY) { "load", configure_load }, -#endif #if defined(KORE_USE_PYTHON) { "python_import", configure_python_import }, #endif @@ -314,7 +312,6 @@ configure_bind(char *options) return (kore_server_bind(argv[0], argv[1], argv[2])); } -#if !defined(KORE_SINGLE_BINARY) static int configure_load(char *options) { @@ -327,7 +324,8 @@ configure_load(char *options) kore_module_load(argv[0], argv[1], KORE_MODULE_NATIVE); return (KORE_RESULT_OK); } -#else + +#if defined(KORE_SINGLE_BINARY) static FILE * config_file_write(void) { diff --git a/src/module.c b/src/module.c @@ -63,9 +63,7 @@ kore_module_cleanup(void) void kore_module_load(const char *path, const char *onload, int type) { -#if !defined(KORE_SINGLE_BINARY) struct stat st; -#endif struct kore_module *module; kore_debug("kore_module_load(%s, %s)", path, onload); @@ -76,16 +74,16 @@ kore_module_load(const char *path, const char *onload, int type) module->onload = NULL; module->handle = NULL; -#if !defined(KORE_SINGLE_BINARY) - if (stat(path, &st) == -1) - fatal("stat(%s): %s", path, errno_s); + if (path != NULL) { + if (stat(path, &st) == -1) + fatal("stat(%s): %s", path, errno_s); - module->path = kore_strdup(path); - module->mtime = st.st_mtime; -#else - module->path = NULL; - module->mtime = 0; -#endif + module->path = kore_strdup(path); + module->mtime = st.st_mtime; + } else { + module->path = NULL; + module->mtime = 0; + } switch (module->type) { case KORE_MODULE_NATIVE: @@ -120,22 +118,19 @@ kore_module_load(const char *path, const char *onload, int type) void kore_module_onload(void) { -#if !defined(KORE_SINGLE_BINARY) struct kore_module *module; TAILQ_FOREACH(module, &modules, list) { - if (module->ocb == NULL) + if (module->path == NULL || module->ocb == NULL) continue; kore_runtime_onload(module->ocb, KORE_MODULE_LOAD); } -#endif } void kore_module_reload(int cbs) { -#if !defined(KORE_SINGLE_BINARY) struct stat st; int ret; struct kore_domain *dom; @@ -143,6 +138,9 @@ kore_module_reload(int cbs) struct kore_module *module; TAILQ_FOREACH(module, &modules, list) { + if (module->path == NULL) + continue; + if (stat(module->path, &st) == -1) { kore_log(LOG_NOTICE, "stat(%s): %s, skipping reload", module->path, errno_s); @@ -198,7 +196,6 @@ kore_module_reload(int cbs) #if !defined(KORE_NO_HTTP) kore_validator_reload(); #endif -#endif } int