A couple of clean up functions to help valgrind.
authorDave West <davew@uncensored.citadel.org>
Thu, 6 Dec 2007 23:19:26 +0000 (23:19 +0000)
committerDave West <davew@uncensored.citadel.org>
Thu, 6 Dec 2007 23:19:26 +0000 (23:19 +0000)
citadel/serv_extensions.c
citadel/serv_extensions.h
citadel/sysdep.c

index be0e74815858dd98404d2a9aa479bf98c57b91db..026af0680ac64500d8dbf896513c9369aef9e88c 100644 (file)
@@ -1156,6 +1156,21 @@ int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module,
        return 0;
 }
 
+void CtdlDestroyDirectoryServiceFuncs(void)
+{
+       struct DirectoryServiceHook *cur, *next;
+       
+       cur = DirectoryServiceHookList;
+       DirectoryServiceHookList = NULL;
+       while (cur)
+       {
+               next = cur->next;
+               CtdlLogPrintf(CTDL_INFO, "Destroyed directory service function for module %s.\n", cur->module);
+               free(cur);
+               cur = next;
+       }
+}
+
 /*
  * Dirty hack until we impliment a hook mechanism for this
  */
index 9a658b0366acc062061099be6738116c1a58685a..9256798e5d1daf8e08682fd928782d2b65226730 100644 (file)
@@ -200,4 +200,6 @@ int PerformFixedOutputHooks(char *, char *, int);
 
 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, char *search_string, char *func_name);
 
+void CtdlDestroyDirectoryServiceFuncs(void);
+
 #endif /* SERV_EXTENSIONS_H */
index 17e40ce57482ea80b1c1dac65ded41b3b676052e..90fff43e59c600d10af566abb15a42f3c0941d5b 100644 (file)
@@ -793,7 +793,10 @@ void context_cleanup(void)
        /* We need to update the ContextList because some modules may want to itterate it
         * Question is should we NULL it before iterating here or should we just keep updating it
         * as we remove items?
+        *
+        * Answer is to NULL it first to prevent modules from doing any actions on the list at all
         */
+       ContextList=NULL;
        while (ptr != NULL){
                /* Remove the session from the active list */
                rem = ptr->next;
@@ -803,7 +806,6 @@ void context_cleanup(void)
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;
-               ContextList = rem; // Update ContextList since a module may try to iterate the list.
        }
 }
 
@@ -851,6 +853,8 @@ void sysdep_master_cleanup(void) {
        CtdlDestroyFixedOutputHooks();  
        CtdlDestroySessionHooks();
        CtdlDestroyServiceHook();
+       CtdlDestroyRoomHooks();
+       CtdlDestroyDirectoryServiceFuncs();
        #ifdef HAVE_BACKTRACE
        eCrash_Uninit();
        #endif