mirror of https://git.kore.io/kore.git
Revert "automatically resolve existing symbols upon reload."
This isn't ready yet.
This commit is contained in:
parent
ed4ef22f1b
commit
2eab2f1ed7
|
@ -625,9 +625,6 @@ int kore_module_handler_new(const char *, const char *,
|
||||||
const char *, const char *, int);
|
const char *, const char *, int);
|
||||||
void kore_module_handler_free(struct kore_module_handle *);
|
void kore_module_handler_free(struct kore_module_handle *);
|
||||||
|
|
||||||
void kore_runtime_init(void);
|
|
||||||
void kore_runtime_reload(void);
|
|
||||||
void kore_runtime_cleanup(void);
|
|
||||||
struct kore_runtime_call *kore_runtime_getcall(const char *);
|
struct kore_runtime_call *kore_runtime_getcall(const char *);
|
||||||
|
|
||||||
void kore_runtime_execute(struct kore_runtime_call *);
|
void kore_runtime_execute(struct kore_runtime_call *);
|
||||||
|
@ -651,6 +648,7 @@ struct kore_module_handle *kore_module_handler_find(const char *,
|
||||||
|
|
||||||
#if !defined(KORE_NO_HTTP)
|
#if !defined(KORE_NO_HTTP)
|
||||||
void kore_validator_init(void);
|
void kore_validator_init(void);
|
||||||
|
void kore_validator_reload(void);
|
||||||
int kore_validator_add(const char *, u_int8_t, const char *);
|
int kore_validator_add(const char *, u_int8_t, const char *);
|
||||||
int kore_validator_run(struct http_request *, const char *, char *);
|
int kore_validator_run(struct http_request *, const char *, char *);
|
||||||
int kore_validator_check(struct http_request *,
|
int kore_validator_check(struct http_request *,
|
||||||
|
|
|
@ -166,10 +166,9 @@ main(int argc, char *argv[])
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
kore_mem_init();
|
kore_mem_init();
|
||||||
kore_runtime_init();
|
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
fatal("did you mean to run `kodev` instead?");
|
fatal("did you mean to run `kodev´ instead?");
|
||||||
|
|
||||||
kore_pid = getpid();
|
kore_pid = getpid();
|
||||||
nlisteners = 0;
|
nlisteners = 0;
|
||||||
|
@ -236,7 +235,6 @@ main(int argc, char *argv[])
|
||||||
kore_python_cleanup();
|
kore_python_cleanup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kore_runtime_cleanup();
|
|
||||||
kore_mem_cleanup();
|
kore_mem_cleanup();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
16
src/module.c
16
src/module.c
|
@ -134,6 +134,8 @@ kore_module_reload(int cbs)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ret;
|
int ret;
|
||||||
|
struct kore_domain *dom;
|
||||||
|
struct kore_module_handle *hdlr;
|
||||||
struct kore_module *module;
|
struct kore_module *module;
|
||||||
|
|
||||||
TAILQ_FOREACH(module, &modules, list) {
|
TAILQ_FOREACH(module, &modules, list) {
|
||||||
|
@ -180,7 +182,19 @@ kore_module_reload(int cbs)
|
||||||
kore_log(LOG_NOTICE, "reloaded '%s' module", module->path);
|
kore_log(LOG_NOTICE, "reloaded '%s' module", module->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
kore_runtime_reload();
|
TAILQ_FOREACH(dom, &domains, list) {
|
||||||
|
TAILQ_FOREACH(hdlr, &(dom->handlers), list) {
|
||||||
|
kore_free(hdlr->rcall);
|
||||||
|
hdlr->rcall = kore_runtime_getcall(hdlr->func);
|
||||||
|
if (hdlr->rcall == NULL)
|
||||||
|
fatal("no function '%s' found", hdlr->func);
|
||||||
|
hdlr->errors = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(KORE_NO_HTTP)
|
||||||
|
kore_validator_reload();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -51,61 +51,13 @@ struct kore_runtime kore_native_runtime = {
|
||||||
.execute = native_runtime_execute
|
.execute = native_runtime_execute
|
||||||
};
|
};
|
||||||
|
|
||||||
struct symbol {
|
|
||||||
char *name;
|
|
||||||
struct kore_runtime_call *rcall;
|
|
||||||
TAILQ_ENTRY(symbol) list;
|
|
||||||
};
|
|
||||||
|
|
||||||
static TAILQ_HEAD(, symbol) resolved_symbols;
|
|
||||||
|
|
||||||
void
|
|
||||||
kore_runtime_init(void)
|
|
||||||
{
|
|
||||||
TAILQ_INIT(&resolved_symbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kore_runtime_cleanup(void)
|
|
||||||
{
|
|
||||||
struct symbol *sym;
|
|
||||||
|
|
||||||
while ((sym = TAILQ_FIRST(&resolved_symbols)) != NULL) {
|
|
||||||
TAILQ_REMOVE(&resolved_symbols, sym, list);
|
|
||||||
kore_free(sym->name);
|
|
||||||
kore_free(sym);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kore_runtime_reload(void)
|
|
||||||
{
|
|
||||||
void *ptr;
|
|
||||||
struct symbol *sym;
|
|
||||||
struct kore_runtime *runtime;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(sym, &resolved_symbols, list) {
|
|
||||||
ptr = kore_module_getsym(sym->name, &runtime);
|
|
||||||
if (ptr == NULL)
|
|
||||||
fatal("required symbol '%s' not found", sym->name);
|
|
||||||
sym->rcall->runtime = runtime;
|
|
||||||
sym->rcall->addr = ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct kore_runtime_call *
|
struct kore_runtime_call *
|
||||||
kore_runtime_getcall(const char *symbol)
|
kore_runtime_getcall(const char *symbol)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
struct symbol *sym;
|
|
||||||
struct kore_runtime_call *rcall;
|
struct kore_runtime_call *rcall;
|
||||||
struct kore_runtime *runtime;
|
struct kore_runtime *runtime;
|
||||||
|
|
||||||
TAILQ_FOREACH(sym, &resolved_symbols, list) {
|
|
||||||
if (!strcmp(sym->name, symbol))
|
|
||||||
return (sym->rcall);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = kore_module_getsym(symbol, &runtime);
|
ptr = kore_module_getsym(symbol, &runtime);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -114,11 +66,6 @@ kore_runtime_getcall(const char *symbol)
|
||||||
rcall->addr = ptr;
|
rcall->addr = ptr;
|
||||||
rcall->runtime = runtime;
|
rcall->runtime = runtime;
|
||||||
|
|
||||||
sym = kore_malloc(sizeof(*sym));
|
|
||||||
sym->name = kore_strdup(symbol);
|
|
||||||
sym->rcall = rcall;
|
|
||||||
TAILQ_INSERT_TAIL(&resolved_symbols, sym, list);
|
|
||||||
|
|
||||||
return (rcall);
|
return (rcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,22 @@ kore_validator_check(struct http_request *req, struct kore_validator *val,
|
||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kore_validator_reload(void)
|
||||||
|
{
|
||||||
|
struct kore_validator *val;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(val, &validators, list) {
|
||||||
|
if (val->type != KORE_VALIDATOR_TYPE_FUNCTION)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
kore_free(val->rcall);
|
||||||
|
val->rcall = kore_runtime_getcall(val->arg);
|
||||||
|
if (val->rcall == NULL)
|
||||||
|
fatal("no function for validator %s found", val->arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct kore_validator *
|
struct kore_validator *
|
||||||
kore_validator_lookup(const char *name)
|
kore_validator_lookup(const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -446,9 +446,7 @@ kore_worker_entry(struct kore_worker *kw)
|
||||||
|
|
||||||
kore_debug("worker %d shutting down", kw->id);
|
kore_debug("worker %d shutting down", kw->id);
|
||||||
|
|
||||||
kore_runtime_cleanup();
|
|
||||||
kore_mem_cleanup();
|
kore_mem_cleanup();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue