Don't call module onloads until after everything is initialized.

This means the onload functions for a module are now called
after a worker has started and never from the parent ever again.
This commit is contained in:
Joris Vink 2014-06-29 21:15:23 +02:00
parent 8ba29104eb
commit dbd74c4551
4 changed files with 22 additions and 7 deletions

View File

@ -413,7 +413,8 @@ void *kore_mem_find(void *, size_t, void *, u_int32_t);
void kore_domain_init(void);
int kore_domain_new(char *);
void kore_module_init(void);
void kore_module_reload(void);
void kore_module_reload(int);
void kore_module_onload(void);
int kore_module_loaded(void);
void kore_domain_closelogs(void);
void *kore_module_getsym(char *);

View File

@ -257,7 +257,7 @@ kore_server_start(void)
if (sig_recv == SIGHUP || sig_recv == SIGQUIT) {
kore_worker_dispatch_signal(sig_recv);
if (sig_recv == SIGHUP)
kore_module_reload();
kore_module_reload(0);
if (sig_recv == SIGQUIT)
break;
}

View File

@ -55,7 +55,6 @@ kore_module_load(char *path, char *onload)
module->ocb = dlsym(module->handle, onload);
if (module->ocb == NULL)
fatal("%s: onload '%s' not present", path, onload);
module->ocb(KORE_MODULE_LOAD);
}
if (kore_cb_name != NULL && kore_cb == NULL)
@ -65,7 +64,20 @@ kore_module_load(char *path, char *onload)
}
void
kore_module_reload(void)
kore_module_onload(void)
{
struct kore_module *module;
TAILQ_FOREACH(module, &modules, list) {
if (module->ocb == NULL)
continue;
module->ocb(KORE_MODULE_LOAD);
}
}
void
kore_module_reload(int cbs)
{
struct stat st;
struct kore_domain *dom;
@ -84,7 +96,7 @@ kore_module_reload(void)
if (module->mtime == st.st_mtime)
continue;
if (module->ocb != NULL)
if (module->ocb != NULL && cbs == 1)
module->ocb(KORE_MODULE_UNLOAD);
module->mtime = st.st_mtime;
@ -102,7 +114,8 @@ kore_module_reload(void)
module->path, module->onload);
}
module->ocb(KORE_MODULE_LOAD);
if (cbs)
module->ocb(KORE_MODULE_LOAD);
}
if (kore_cb_name != NULL && kore_cb == NULL)

View File

@ -239,11 +239,12 @@ kore_worker_entry(struct kore_worker *kw)
worker->accept_treshold = worker_max_connections / 10;
kore_log(LOG_NOTICE, "worker %d started (cpu#%d)", kw->id, kw->cpu);
kore_module_onload();
for (;;) {
if (sig_recv != 0) {
if (sig_recv == SIGHUP)
kore_module_reload();
kore_module_reload(1);
else if (sig_recv == SIGQUIT)
quit = 1;
sig_recv = 0;