From: Dave West Date: Thu, 6 Dec 2007 23:19:26 +0000 (+0000) Subject: A couple of clean up functions to help valgrind. X-Git-Tag: v7.86~2667 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=de9185ffeae5d32f6ad6cddf17756165ec3305e7 A couple of clean up functions to help valgrind. --- diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index be0e74815..026af0680 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -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 */ diff --git a/citadel/serv_extensions.h b/citadel/serv_extensions.h index 9a658b036..9256798e5 100644 --- a/citadel/serv_extensions.h +++ b/citadel/serv_extensions.h @@ -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 */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 17e40ce57..90fff43e5 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -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