diff --git a/Changes b/Changes index a92b0f74d..93c46ce83 100644 --- a/Changes +++ b/Changes @@ -633,3 +633,5 @@ seen. gmtime warning still there - Fixed a pthread_join - Rewrote updconf a bit, should work flawlessly now (?) - Made a minor message change to ./Setup +- Fixed some minor mod_load troubles, and made it go a little more sensible + regarding retarded rehashes diff --git a/include/modules.h b/include/modules.h index 7c4e41fa9..079ddd6c4 100644 --- a/include/modules.h +++ b/include/modules.h @@ -94,11 +94,19 @@ void del_HookX(int hooktype, int (*intfunc)(), void (*voidfunc)()); #define RunHookReturn(hooktype,x,ret) for (global_i = Hooks[hooktype]; global_i; global_i = global_i->next) if((*(global_i->func.intfunc))(x) ret) return #define RunHook2(hooktype,x,y) for (global_i = Hooks[hooktype]; global_i; global_i = global_i->next) (*(global_i->func.intfunc))(x,y) + +/* Hook types */ #define HOOKTYPE_LOCAL_QUIT 1 #define HOOKTYPE_LOCAL_NICKCHANGE 2 #define HOOKTYPE_LOCAL_CONNECT 3 -#define HOOKTYPE_SCAN_HOST 4 -#define HOOKTYPE_SCAN_INFO 5 +#define HOOKTYPE_SCAN_HOST 4 /* Taken care of in scan.c */ +#define HOOKTYPE_SCAN_INFO 5 /* Taken care of in scan.c */ #define HOOKTYPE_CONFIG_UNKNOWN 6 #define HOOKTYPE_REHASH 7 #define HOOKTYPE_PRE_LOCAL_CONNECT 8 + + +/* Module flags */ +#define MODFLAG_NONE 0x0000 +#define MODFLAG_LOADED 0x0001 /* (mod_load has been called and suceeded) */ + diff --git a/src/modules.c b/src/modules.c index c0a5735f4..3c8307e39 100644 --- a/src/modules.c +++ b/src/modules.c @@ -46,15 +46,18 @@ #define RTLD_NOW RTLD_LAZY #endif -ModuleInfo *Modules[MAXMODULES]; -Hook *Hooks[MAXHOOKTYPES]; -Hook *global_i = NULL; +ModuleInfo *Modules[MAXMODULES]; +unsigned char ModuleFlags[MAXMODULES]; +Hook *Hooks[MAXHOOKTYPES]; +Hook *global_i = NULL; + int modules_loaded = 0; void module_init(void) { bzero(Modules, sizeof(Modules)); bzero(Hooks, sizeof(Hooks)); + bzero(ModuleFlags, sizeof(ModuleFlags)); modules_loaded = 0; } @@ -178,11 +181,6 @@ int load_module(char *module, int module_load) mod_header->dll = Mod; mod_header->unload = mod_unload; - mod_load = irc_dlsym(Mod, "mod_load"); - if (!mod_load) - { - mod_load = irc_dlsym(Mod, "_mod_load"); - } if ((*mod_init)(module_load) < 0) { config_progress @@ -193,21 +191,17 @@ int load_module(char *module, int module_load) return -1; } - if (mod_load) + ModuleFlags[i] = NULL; + if (module_load) { - /* if ircd is booted, load it */ - if (loop.ircd_booted) + mod_load = irc_dlsym(Mod, "mod_load"); + if (!mod_load) { - if ((*mod_load)() < 0) + mod_load = irc_dlsym(Mod, "_mod_load"); + if (mod_load) { - config_progress - ("Failed to load module %s: mod_load failed", - module); - (*mod_unload)(); - Modules[i] = NULL; - irc_dlclose(Mod); - return -1; - + (*mod_load)(module_load); + ModuleFlags[i] |= MODFLAG_LOADED; } } } @@ -244,6 +238,7 @@ void unload_all_modules(void) irc_dlclose(Modules[i]->dll); Modules[i] = NULL; + ModuleFlags[i] = MODFLAG_NONE; modules_loaded--; } #endif @@ -268,6 +263,7 @@ int unload_module(char *name) irc_dlclose(Modules[i]->dll); Modules[i] = NULL; + ModuleFlags[i] = MODFLAG_NONE; modules_loaded--; return 1; #endif @@ -303,15 +299,13 @@ vFP module_sym(char *name) } -void module_loadall() +void module_loadall(int module_load) { #ifndef STATIC_LINKING - vFP fp; - char buf[512]; + iFP fp; int i; ModuleInfo *mi; - ircsprintf(buf, "_mod_load"); if (!loop.ircd_booted) { sendto_realops("Ehh, !loop.ircd_booted in module_loadall()"); @@ -323,12 +317,13 @@ void module_loadall() mi = Modules[i]; if (!mi) continue; - - if (fp = (vFP) irc_dlsym(mi->dll, "mod_load")) + if (ModuleFlags[i] & MODFLAG_LOADED) + continue; + if (fp = (iFP) irc_dlsym(mi->dll, "mod_load")) { } else - if (fp = (vFP) irc_dlsym(mi->dll, buf)) + if (fp = (iFP) irc_dlsym(mi->dll, "_mod_load")) { } else @@ -337,7 +332,15 @@ void module_loadall() continue; } /* Call the module_load */ - (*fp)(); + if ((*fp)(module_load) < 0) + { + config_error("cannot load module %s", mi->name); + } + else + { + ModuleFlags[i] |= MODFLAG_LOADED; + } + } #endif } diff --git a/src/modules/scan.c b/src/modules/scan.c index 1a1bfc5b9..328a620fe 100644 --- a/src/modules/scan.c +++ b/src/modules/scan.c @@ -134,7 +134,6 @@ DLLFUNC int mod_load(int module_load) int m_scan_load(int module_load) #endif { - if (!blackhole_conf.ip || !blackhole_conf.port) { config_progress("set::blackhole: missing ip/port mask or configuration not loaded. using %s:6013", @@ -163,6 +162,7 @@ int m_scan_load(int module_load) listen(blackholefd, LISTEN_SIZE); /* Create blackhole accept() thread */ IRCCreateThread(acceptthread, acceptthread_attr, blackhole, NULL); + return 0; } @@ -420,6 +420,8 @@ DLLFUNC int h_config_set_blackhole(void) char *ip; char *port; int iport; + if (blackhole_conf.ip) + MyFree(blackhole_conf.ip); for (sets = conf_unknown_set; sets; sets = (ConfigItem_unknown_ext *)sets->next) { diff --git a/src/s_conf.c b/src/s_conf.c index 9bc7e8042..996624b9d 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -3349,6 +3349,7 @@ int rehash(aClient *cptr, aClient *sptr, int sig) } /* rehash_modules */ init_conf2(configfile); + module_loadall(0); /* Clean up listen records */ close_listeners(); listen_cleanup();