]> code.citadel.org Git - citadel.git/blobdiff - citadel/file_ops.c
Memleak: free the nttlist (network host list) on exit
[citadel.git] / citadel / file_ops.c
index 0438b244e2870ff6625baa56cdcd58278cc78c20..e4453cbdbdc3b97f055403caa48dc0a467f57e7c 100644 (file)
@@ -1,8 +1,5 @@
 /* 
- * $Id$
- *
  * Server functions which handle file transfers and room directories.
- *
  */
 
 #include "sysdep.h"
@@ -35,7 +32,6 @@
 #include "config.h"
 #include "file_ops.h"
 #include "sysdep_decls.h"
-#include "user_ops.h"
 #include "support.h"
 #include "room_ops.h"
 #include "msgbase.h"
 #endif
 
 #include "ctdl_module.h"
+#include "user_ops.h"
 
 /*
  * network_talking_to()  --  concurrency checker
  */
+static char *nttlist = NULL;
 int network_talking_to(char *nodename, int operation) {
 
-       static char *nttlist = NULL;
        char *ptr = NULL;
        int i;
        char buf[SIZ];
@@ -105,6 +102,14 @@ int network_talking_to(char *nodename, int operation) {
        return(retval);
 }
 
+void cleanup_nttlist(void)
+{
+        begin_critical_section(S_NTTLIST);
+       if (nttlist != NULL)
+               free(nttlist);
+       nttlist = NULL;
+        end_critical_section(S_NTTLIST);
+}
 
 
 
@@ -580,7 +585,6 @@ void cmd_ucls(char *cmd)
        CC->upload_fp = NULL;
 
        if ((!strcasecmp(cmd, "1")) && (CC->upload_type != UPL_FILE)) {
-               CC->upload_type = UPL_FILE;
                cprintf("%d Upload completed.\n", CIT_OK);
 
                if (CC->upload_type == UPL_NET) {
@@ -605,6 +609,7 @@ void cmd_ucls(char *cmd)
                        /* FIXME ... here we need to trigger a network run */
                }
 
+               CC->upload_type = UPL_FILE;
                return;
        }
 
@@ -827,7 +832,8 @@ CTDL_MODULE_INIT(file_ops)
                CtdlRegisterProtoHook(cmd_nuop, "NUOP", "Open a network spool file for upload");
                CtdlRegisterProtoHook(cmd_oimg, "OIMG", "Open an image file for download");
                CtdlRegisterProtoHook(cmd_uimg, "UIMG", "Upload an image file");
+               CtdlRegisterCleanupHook(cleanup_nttlist);
        }
         /* return our Subversion id for the Log */
-       return "$Id$";
+       return "file_ops";
 }