]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/modules.c
CHANSERV: tell user when they can't attempts to auth any more, and drop max attempts...
[irc/quakenet/newserv.git] / core / modules.c
index 520c4fd223517ed2210d62c2c795cef4ec0b93ea..6bdd7a2ef100bf56d52694794e20687156608e9f 100644 (file)
@@ -12,6 +12,7 @@
 #include "../lib/irc_string.h"
 #include "../lib/splitline.h"
 #include "../lib/strlfunc.h"
+#include "../lib/valgrind.h"
 #include "config.h"
 #include "error.h"
 #include <stdio.h>
@@ -323,7 +324,7 @@ int isloaded(char *modulename) {
 }
 
 
-int rmmod(char *modulename) {
+int rmmod(char *modulename, int close) {
   int i,j;
   module *mods;
   struct module_dep *mdp;
@@ -339,7 +340,7 @@ int rmmod(char *modulename) {
   if ((mdp=getmoduledep(modulebuf))) {
     for (j=0;j<mdp->numchildren;j++) {
       if (isloaded(mdp->children[j]->name->content)) {
-        if (rmmod(mdp->children[j]->name->content)) {
+        if (rmmod(mdp->children[j]->name->content, close)) {
           Error("core",ERR_WARNING,"Unable to remove child module %s (depends on %s)",
                  mdp->children[j]->name->content, modulebuf);
           return 1;
@@ -357,16 +358,18 @@ int rmmod(char *modulename) {
   
   mods=(module *)(modules.content);
     
+  if (!close
 #ifdef BROKEN_DLCLOSE
-  {
+      || 1
+#endif
+     ) {
     void (*fini)();
     fini = dlsym(mods[i].handle, "__fini");
     if(!dlerror())
       fini();
-  }
-#endif
+  } else
+    dlclose(mods[i].handle);
 
-  dlclose(mods[i].handle);
   freesstring(mods[i].name);
   array_delslot(&modules,i);
 
@@ -434,7 +437,7 @@ void safereloadcallback(void *arg) {
     return;
   
   preparereload(safereload_str->content);
-  rmmod(safereload_str->content);
+  rmmod(safereload_str->content, 1);
   insmod(safereload_str->content);
   reloadmarked();
 
@@ -462,7 +465,11 @@ void newserv_shutdown() {
     mods=(module *)(modules.content);
 
     strlcpy(buf, mods[0].name->content, sizeof(buf));
-    rmmod(buf);
+
+    /* Unload the module unless we're running on Valgrind -
+     * in which case unloading the module would invalidate
+     * stacktraces Valgrind has captured so far. */
+    rmmod(buf, !RUNNING_ON_VALGRIND);
   }
   
   clearmoduledeps();