diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/modules.c | 40 |
2 files changed, 26 insertions, 20 deletions
diff --git a/src/main.c b/src/main.c index 23167e0e9..e274e2504 100644 --- a/src/main.c +++ b/src/main.c @@ -223,6 +223,7 @@ static void services_restart(void) #if defined(LINUX20) || defined(LINUX22) pthread_kill_other_threads_np(); #endif + modules_unload_all(true); execve(SERVICES_BIN, my_av, my_envp); if (!readonly) { open_log(); @@ -275,7 +276,7 @@ static void services_shutdown(void) } send_event(EVENT_SHUTDOWN, 1, EVENT_STOP); disconn(servsock); - modules_unload_all(); /* Only legitimate use of this function */ + modules_unload_all(true); /* Only legitimate use of this function */ } /*************************************************************************/ @@ -355,6 +356,7 @@ void sighandler(int signum) inbuf[448] = 0; } wallops(NULL, "PANIC! buffer = %s\r\n", inbuf); + modules_unload_all(false); } else if (waiting < 0) { /* This is static on the off-chance we run low on stack */ static char buf[BUFSIZE]; @@ -412,6 +414,7 @@ void sighandler(int signum) } wallops(NULL, "PANIC! %s (%s)", buf, strsignal(signum)); alog("PANIC! %s (%s)", buf, strsignal(signum)); + modules_unload_all(false); } } @@ -433,6 +436,7 @@ void sighandler(int signum) if (signum == SIGSEGV) { do_backtrace(1); + modules_unload_all(false); /* probably cant do this, but might as well try, we have nothing left to loose */ } /* Should we send the signum here as well? -GD */ send_event(EVENT_SIGNAL, 1, quitmsg); diff --git a/src/modules.c b/src/modules.c index 6825bb1db..8c37fb61c 100644 --- a/src/modules.c +++ b/src/modules.c @@ -207,36 +207,38 @@ void modules_delayed_init(void) * And if that isn't enough discouragement, you'll wake up with your * both legs broken tomorrow ;) -GD */ -void modules_unload_all(void) +void modules_unload_all(boolean fini) { #ifdef USE_MODULES int idx; ModuleHash *mh, *next; - void (*func) (void); - + void (*func) (void); + for (idx = 0; idx < MAX_CMD_HASH; idx++) { mh = MODULE_HASH[idx]; while (mh) { next = mh->next; - - if (prepForUnload(mh->m) != MOD_ERR_OK) { - mh = next; + if(fini) { + if (prepForUnload(mh->m) != MOD_ERR_OK) { + mh = next; continue; - } + } - func = (void (*)(void))ano_modsym(mh->m->handle, "AnopeFini"); - if (func) { - mod_current_module_name = mh->m->name; - func(); /* exec AnopeFini */ - mod_current_module_name = NULL; - } - - if ((ano_modclose(mh->m->handle)) != 0) - alog(ano_moderr()); - else - delModule(mh->m); + func = (void (*)(void))ano_modsym(mh->m->handle, "AnopeFini"); + if (func) { + mod_current_module_name = mh->m->name; + func(); /* exec AnopeFini */ + mod_current_module_name = NULL; + } - mh = next; + if ((ano_modclose(mh->m->handle)) != 0) + alog(ano_moderr()); + else + delModule(mh->m); + } else { + delModule(mh->m); + } + mh = next; } } #endif |