]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_extensions.c
* don't free stacked pointers
[citadel.git] / citadel / serv_extensions.c
index c74dcb6d3901ac3a442b94ef761f6a8693e2136f..ae8ebfbc0258b6ad3b7972dac9486700a68359f6 100644 (file)
@@ -1,9 +1,6 @@
 /*
- * $Id$
- *
  * Citadel Dynamic Loading Module
  * Written by Brian Costello <btx@calyx.net>
- *
  */
 
 #include "sysdep.h"
@@ -769,7 +766,6 @@ void CtdlRegisterServiceHook(int tcp_port,
                AddPortError(message, error);
                strcat(message, "FAILED.");
                CtdlLogPrintf(CTDL_CRIT, "%s\n", message);
-               free(error);
                free(newfcn);
        }
        free(message);
@@ -784,7 +780,8 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
 {
        struct ServiceFunctionHook *cur, *p;
 
-       for (cur = ServiceHookTable; cur != NULL; cur = cur->next) {
+       cur = ServiceHookTable;
+       while (cur != NULL) {
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                !(sockpath && cur->sockpath &&
@@ -812,6 +809,32 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
        }
 }
 
+
+void CtdlShutdownServiceHooks(void)
+{
+       /* sort of a duplicate of close_masters() but called earlier */
+       struct ServiceFunctionHook *cur;
+
+       cur = ServiceHookTable;
+       while (cur != NULL) 
+       {
+               if (cur->msock != -1)
+               {
+                       close(cur->msock);
+                       cur->msock = -1;
+                       if (cur->sockpath != NULL){
+                               CtdlLogPrintf(CTDL_INFO, "[%s] Closed UNIX domain socket %s\n",
+                                             cur->ServiceName,
+                                             cur->sockpath);
+                       } else {
+                               CtdlLogPrintf(CTDL_INFO, "[%s] closing service\n", 
+                                             cur->ServiceName);
+                       }
+               }
+               cur = cur->next;
+       }
+}
+
 void CtdlDestroyServiceHook(void)
 {
        struct ServiceFunctionHook *cur, *p;