No more cleanup hooks. The OS can reclaim memory better than we can. We want to...
authorArt Cancro <ajc@citadel.org>
Sun, 24 Jan 2021 00:55:49 +0000 (19:55 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 24 Jan 2021 00:55:49 +0000 (19:55 -0500)
16 files changed:
citadel/citserver.c
citadel/control.c
citadel/database.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/fulltext/ft_wordbreaker.c
citadel/modules/fulltext/serv_fulltext.c
citadel/modules/imap/serv_imap.c
citadel/modules/inetcfg/serv_inetcfg.c
citadel/modules/network/serv_network.c
citadel/modules/nntp/serv_nntp.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/xmpp_queue.c
citadel/serv_extensions.c
citadel/serv_extensions.h
citadel/sysdep.c

index b9648f6f70a3ba3b3b5759e992d1069477583070..a071b2b72f09e42cae26b59b5b62969b4e61061e 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * Main source module for the Citadel server
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -123,7 +123,6 @@ void master_startup(void)
  */
 int master_cleanup(int exitcode)
 {
-       struct CleanupFunctionHook *fcn;
        static int already_cleaning_up = 0;
 
        if (already_cleaning_up) {
@@ -133,11 +132,6 @@ int master_cleanup(int exitcode)
        }
        already_cleaning_up = 1;
 
-       /* Run any cleanup routines registered by loadable modules */
-       for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
-               (*fcn->h_function_pointer) ();
-       }
-
        /* Do system-dependent stuff */
        sysdep_master_cleanup();
 
@@ -145,7 +139,7 @@ int master_cleanup(int exitcode)
        shutdown_config_system();
 
        /* Close databases */
-       syslog(LOG_INFO, "Closing databases\n");
+       syslog(LOG_INFO, "citserver: closing databases");
        close_databases();
 
        /* If the operator requested a halt but not an exit, halt here. */
index 936deae33c2b5643eb8806994586d44700ca4eb4..3ab6ac84fa3a8918bd9135cfc6d1906fbf9c68b5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module handles states which are global to the entire server.
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -791,10 +791,6 @@ void cmd_gvdn(char *argbuf)
 /*                      MODULE INITIALIZATION STUFF                          */
 /*****************************************************************************/
 
-void control_cleanup(void)
-{
-       DeleteHash(&CfgNameHash);
-}
 CTDL_MODULE_INIT(control)
 {
        if (!threading) {
@@ -806,8 +802,6 @@ CTDL_MODULE_INIT(control)
 
                CtdlRegisterProtoHook(cmd_gvdn, "GVDN", "get valid domain names");
                CtdlRegisterProtoHook(cmd_conf, "CONF", "get/set system configuration");
-               CtdlRegisterCleanupHook(control_cleanup);
-
        }
        /* return our id for the Log */
        return "control";
index 0f6121e1fa7837865bb7f9f808e89632d4b739aa..2f6a5b5cedfe41f1b17fa58a0aba7a0cc037ef05 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This is a data store backend for the Citadel server which uses Berkeley DB.
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 3.
@@ -317,7 +317,7 @@ void close_databases(void) {
 
        syslog(LOG_INFO, "db: performing final checkpoint");
        if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) {
-               syslog(LOG_ERR, "txn_checkpoint: %s", db_strerror(ret));
+               syslog(LOG_ERR, "db: txn_checkpoint: %s", db_strerror(ret));
        }
 
        syslog(LOG_INFO, "db: flushing the database logs");
@@ -325,11 +325,6 @@ void close_databases(void) {
                syslog(LOG_ERR, "db: log_flush: %s", db_strerror(ret));
        }
 
-#ifdef DB_STAT_ALL
-       /* print some statistics... */
-       dbenv->lock_stat_print(dbenv, DB_STAT_ALL);
-#endif
-
        /* close the tables */
        syslog(LOG_INFO, "db: closing databases");
        for (i = 0; i < MAXCDB; ++i) {
@@ -341,6 +336,12 @@ void close_databases(void) {
 
        }
 
+       // This seemed nifty at the time but did anyone really look at it?
+       // #ifdef DB_STAT_ALL
+       // /* print some statistics... */
+       // dbenv->lock_stat_print(dbenv, DB_STAT_ALL);
+       // #endif
+
        /* Close the handle. */
        ret = dbenv->close(dbenv, 0);
        if (ret) {
index 83afa539bf60aafb66a1a2e8878b1c2bd8939f65..941806393d1a33e6b8f3a60fe7dc3562f22d2f46 100644 (file)
@@ -3,7 +3,7 @@
  * room on a Citadel server.  It handles iCalendar objects using the
  * iTIP protocol.  See RFCs 2445 and 2446.
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -2532,11 +2532,6 @@ void ical_fixed_output(char *ptr, int len) {
 }
 
 
-void serv_calendar_destroy(void) {
-       icaltimezone_free_builtin_timezones();
-}
-
-
 /*
  * Register this module with the Citadel server.
  */
@@ -2565,7 +2560,6 @@ CTDL_MODULE_INIT(calendar)
                CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP, PRIO_STOP + 80);
                CtdlRegisterFixedOutputHook("text/calendar", ical_fixed_output);
                CtdlRegisterFixedOutputHook("application/ics", ical_fixed_output);
-               CtdlRegisterCleanupHook(serv_calendar_destroy);
        }
 
        /* return our module name for the log */
index b2ba828bb8406a77e8ec28b66c2d7e0eceb2f319..968fa9f02b0aa2bf21ddf87890a0e19887d8a56a 100644 (file)
@@ -147,26 +147,6 @@ void initialize_noise_words(void)
 }
 
 
-void noise_word_cleanup(void)
-{
-       int i;
-       noise_word *cur, *next;
-       
-       syslog(LOG_INFO, "wordbreaker: cleaning up fulltext noise words");
-       
-       for (i = 0 ; i < 26 ; i++)
-       {
-               cur = noise_words[i];
-               while (cur)
-               {
-                       next = cur->next;
-                       free(cur->word);
-                       free(cur);
-                       cur = next;
-               }
-       }
-}
-
 /*
  * Compare function
  */
index 1d684111a73cb907420e7591af28b21865f160a9..90c3e3685de18f6fc27f82dc7a93acf9a0db4dd5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This module handles fulltext indexing of the message base.
- * Copyright (c) 2005-2020 by the citadel.org team
+ * Copyright (c) 2005-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -483,7 +483,6 @@ CTDL_MODULE_INIT(fulltext)
                CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
                CtdlRegisterDeleteHook(ft_delete_remove);
                CtdlRegisterSearchFuncHook(ft_search, "fulltext");
-               CtdlRegisterCleanupHook(noise_word_cleanup);
                CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER, PRIO_CLEANUP + 300);
        }
        /* return our module name for the log */
index 7bc97b6ed9745e216117c9edd111d6703410c892..3bc08c213502919294dcffe5a08b3489f43edd52 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IMAP server for the Citadel system
  *
- * Copyright (C) 2000-2018 by Art Cancro and others.
+ * Copyright (C) 2000-2021 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
  * WARNING: the IMAP protocol is badly designed.  No implementation of it
@@ -90,10 +90,6 @@ void registerImapCMD(const char *First, long FLen,
        }
 }
 
-void imap_cleanup(void)
-{
-       DeleteHash(&ImapCmds);
-}
 
 const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params)
 {
@@ -1738,7 +1734,6 @@ CTDL_MODULE_INIT(imap)
                                        NULL, imaps_greeting, imap_command_loop, NULL, CitadelServiceIMAPS);
 #endif
                CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP, PRIO_STOP + 30);
-               CtdlRegisterCleanupHook(imap_cleanup);
        }
        
        /* return our module name for the log */
index 971c672cf598fb381e60d52f7fbb7ed8e68b8bd1..89e8e5633a24136fdc7bdb5d0491c2f8f84611a8 100644 (file)
@@ -4,7 +4,7 @@
  * wrote it as a module merely to keep things as clean and loosely coupled
  * as possible.
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -136,15 +136,6 @@ void inetcfg_init(void) {
 /*****************************************************************************/
 /*                      MODULE INITIALIZATION STUFF                          */
 /*****************************************************************************/
-void cleanup_inetcfg(void)
-{
-       char *buf;
-       buf = inetcfg;
-       inetcfg = NULL;
-       if (buf != NULL) {
-               free(buf);
-       }
-}
 
 
 CTDL_MODULE_INIT(inetcfg)
@@ -153,7 +144,6 @@ CTDL_MODULE_INIT(inetcfg)
        {
                CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE);
                inetcfg_init();
-               CtdlRegisterCleanupHook(cleanup_inetcfg);
        }
        
        /* return our module name for the log */
index 1f610f258f67f2bcb41ddc73d04b04f6a93a6f1c..eeca28afc46a2a40d4107e0711602012fa5465e6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module handles network mail and mailing list processing.
  *
- * Copyright (c) 2000-2019 by the citadel.org team
+ * Copyright (c) 2000-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -191,13 +191,6 @@ void destroy_network_queue_room(RoomProcList *rplist)
        }
 }
 
-void destroy_network_queue_room_locked (void)
-{
-       begin_critical_section(S_RPLIST);
-       destroy_network_queue_room(rplist);
-       end_critical_section(S_RPLIST);
-}
-
 
 /*
  * network_do_queue()
@@ -322,7 +315,6 @@ CTDL_MODULE_INIT(network)
        if (!threading)
        {
                CtdlRegisterRoomHook(network_room_handler);
-               CtdlRegisterCleanupHook(destroy_network_queue_room_locked);
                CtdlRegisterSessionHook(network_do_queue, EVT_TIMER, PRIO_QUEUE + 10);
        }
        return "network";
index 93f65da0a57a3d4582e7d36ed63adde968467669..ef923bb6298733202a43fcc818f47c619883c13b 100644 (file)
@@ -264,15 +264,6 @@ void nntp_quit(void)
 }
 
 
-//
-// Cleanup hook for this module
-//
-void nntp_cleanup(void)
-{
-       /* nothing here yet */
-}
-
-
 //
 // Implements the AUTHINFO USER command (RFC 4643)
 //
@@ -1194,7 +1185,6 @@ CTDL_MODULE_INIT(nntp)
                                        CitadelServiceNNTPS);
 #endif
 
-               CtdlRegisterCleanupHook(nntp_cleanup);
                CtdlRegisterSessionHook(nntp_cleanup_function, EVT_STOP, PRIO_STOP + 250);
        }
        
index 8b03cfca65f9a637c061d064a282cd9f47d4a547..7847eccc31cd49805ac4c0729ec68f7dfd9dc700 100644 (file)
@@ -20,7 +20,7 @@
  * The VRFY and EXPN commands have been removed from this implementation
  * because nobody uses these commands anymore, except for spammers.
  *
- * Copyright (c) 1998-2020 by the citadel.org team
+ * Copyright (c) 1998-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -129,11 +129,6 @@ void registerSmtpCMD(const char *First, long FLen,
 }
 
 
-void smtp_cleanup(void)
-{
-       DeleteHash(&SMTPCmds);
-}
-
 /*
  * Here's where our SMTP session begins its happy day.
  */
@@ -1190,7 +1185,6 @@ CTDL_MODULE_INIT(smtp)
                                        NULL,
                                        CitadelServiceSMTP_LMTP_UNF);
 
-               CtdlRegisterCleanupHook(smtp_cleanup);
                CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP, PRIO_STOP + 250);
        }
        
index 84aa4ba38bbdafee127706d2b3beead9c8443102..1b4d78424fccba42bfb83ff2aff54dbf00131e31 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * XMPP (Jabber) service for the Citadel system
- * Copyright (c) 2007-2019 by Art Cancro and citadel.org
+ * Copyright (c) 2007-2021 by Art Cancro and citadel.org
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -662,7 +662,6 @@ void xmpp_logout_hook(void) {
 
 
 const char *CitadelServiceXMPP="XMPP";
-extern void xmpp_cleanup_events(void);
 CTDL_MODULE_INIT(xmpp)
 {
        if (!threading) {
@@ -678,7 +677,6 @@ CTDL_MODULE_INIT(xmpp)
                 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 90);
                 CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH, PRIO_UNSTEALTH + 1);
                 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH, PRIO_STEALTH + 1);
-               CtdlRegisterCleanupHook(xmpp_cleanup_events);
 
        }
 
index 4e62aece93228381edd2418a9a277f7cd0ccbcf2..da323455f3d063800a63277c24b45fb67a2130a4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * XMPP event queue
  *
- * Copyright (c) 2007-2017 by Art Cancro
+ * Copyright (c) 2007-2021 by Art Cancro
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -138,19 +138,3 @@ void xmpp_process_events(void) {
 
        XMPP->last_event_processed = highest_event;
 }
-
-
-void xmpp_cleanup_events(void)
-{
-        struct xmpp_event *ptr, *ptr2;
-        begin_critical_section(S_XMPP_QUEUE);
-       ptr = xmpp_queue;
-       xmpp_queue = NULL;
-       while (ptr != NULL) {
-               ptr2 = ptr->next;
-               free(ptr);
-               ptr = ptr2;
-       }
-        end_critical_section(S_XMPP_QUEUE);
-
-}
index 3c62694c04706039b3a4ad503fb707e018f96f94..cc594ce655f1a839a636245fa1aaf8116a71c450 100644 (file)
@@ -2,7 +2,7 @@
  * Citadel Extension Loader
  * Originally written by Brian Costello <btx@calyx.net>
  *
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -128,9 +128,6 @@ struct SearchFunctionHook {
 };
 SearchFunctionHook *SearchFunctionHookTable = NULL;
 
-CleanupFunctionHook *CleanupHookTable = NULL;
-CleanupFunctionHook *EVCleanupHookTable = NULL;
-
 ServiceFunctionHook *ServiceHookTable = NULL;
 
 typedef struct ProtoFunctionHook ProtoFunctionHook;
@@ -278,94 +275,6 @@ void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
 }
 
 
-void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
-{
-
-       CleanupFunctionHook *newfcn;
-
-       newfcn = (CleanupFunctionHook *)
-           malloc(sizeof(CleanupFunctionHook));
-       newfcn->next = CleanupHookTable;
-       newfcn->h_function_pointer = fcn_ptr;
-       CleanupHookTable = newfcn;
-
-       syslog(LOG_DEBUG, "extensions: registered a new cleanup function");
-}
-
-
-void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
-{
-       CleanupFunctionHook *cur, *p, *last;
-       last = NULL;
-       cur = CleanupHookTable;
-       while (cur != NULL)
-       {
-               if (fcn_ptr == cur->h_function_pointer)
-               {
-                       syslog(LOG_DEBUG, "extensions: unregistered cleanup function");
-                       p = cur->next;
-
-                       free(cur);
-                       cur = NULL;
-
-                       if (last != NULL)
-                               last->next = p;
-                       else 
-                               CleanupHookTable = p;
-                       cur = p;
-               }
-               else {
-                       last = cur;
-                       cur = cur->next;
-               }
-       }
-}
-
-
-void CtdlRegisterEVCleanupHook(void (*fcn_ptr) (void))
-{
-
-       CleanupFunctionHook *newfcn;
-
-       newfcn = (CleanupFunctionHook *)
-           malloc(sizeof(CleanupFunctionHook));
-       newfcn->next = EVCleanupHookTable;
-       newfcn->h_function_pointer = fcn_ptr;
-       EVCleanupHookTable = newfcn;
-
-       syslog(LOG_DEBUG, "extensions: registered a new cleanup function");
-}
-
-
-void CtdlUnregisterEVCleanupHook(void (*fcn_ptr) (void))
-{
-       CleanupFunctionHook *cur, *p, *last;
-       last = NULL;
-       cur = EVCleanupHookTable;
-       while (cur != NULL)
-       {
-               if (fcn_ptr == cur->h_function_pointer)
-               {
-                       syslog(LOG_DEBUG, "extensions: unregistered cleanup function");
-                       p = cur->next;
-
-                       free(cur);
-                       cur = NULL;
-
-                       if (last != NULL)
-                               last->next = p;
-                       else 
-                               EVCleanupHookTable = p;
-                       cur = p;
-               }
-               else {
-                       last = cur;
-                       cur = cur->next;
-               }
-       }
-}
-
-
 void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType, int Priority)
 {
        SessionFunctionHook *newfcn;
index cd39831ca8ca08d563ad0bc5f32321058f4f789e..677f4f72bb456be00c31df67d85565797645eb06 100644 (file)
@@ -21,13 +21,6 @@ struct ServiceFunctionHook {
 };
 extern ServiceFunctionHook *ServiceHookTable;
 
-typedef struct CleanupFunctionHook CleanupFunctionHook;
-struct CleanupFunctionHook {
-       CleanupFunctionHook *next;
-       void (*h_function_pointer) (void);
-};
-extern CleanupFunctionHook *CleanupHookTable;
-
 void initialize_server_extensions(void);
 int DLoader_Exec_Cmd(char *cmdbuf);
 char *Dynamic_Module_Init(void);
index 6da2bb4431e6a1d48eccb9bd71ad61980d310f9c..61fc7a2c2edf213bbbd97f7db59f2ddca2501502 100644 (file)
@@ -634,8 +634,6 @@ int client_getln(char *buf, int bufsize)
 /*
  * Cleanup any contexts that are left lying around
  */
-
-
 void close_masters (void)
 {
        struct ServiceFunctionHook *serviceptr;