]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/citserver.c
Where gettimeofday() is required, include both time.h and sys/time.h
[citadel.git] / citadel / server / citserver.c
index 4c4fc05f759f28674f9d3e5e78a7ed30afd0f693..016dad7b49cef1c0b56b8d5dc8b10dce56a9be09 100644 (file)
@@ -1,6 +1,6 @@
 // Main source module for the Citadel server
 //
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
@@ -11,8 +11,8 @@
 #include <sys/stat.h>
 #include "sysdep.h"
 #include <time.h>
+#include <sys/time.h>
 #include <libcitadel.h>
-
 #include "ctdl_module.h"
 #include "housekeeping.h"
 #include "locate_host.h"
@@ -67,7 +67,7 @@ void master_startup(void) {
                gid = pw->pw_gid;
        }
 
-       if (create_run_directories(CTDLUID, gid) != 0) {
+       if (create_run_directories(ctdluid, gid) != 0) {
                syslog(LOG_ERR, "citserver: failed to access and create directories");
                exit(1);
        }
@@ -78,7 +78,8 @@ void master_startup(void) {
        syslog(LOG_DEBUG, "citserver: ctdl_run_dir is %s", ctdl_run_dir);
 
        syslog(LOG_INFO, "Opening databases");
-       open_databases();
+       cdb_init_backends();
+       cdb_open_databases();
 
        // Load site-specific configuration
        seed_random_number_generator();                                 // must be done before config system
@@ -120,7 +121,7 @@ void master_startup(void) {
 
 
 // Cleanup routine to be called when the server is shutting down.  Returns the needed exit code.
-int master_cleanup(int exitcode) {
+void master_cleanup(int exitcode) {
        static int already_cleaning_up = 0;
 
        if (already_cleaning_up) {
@@ -130,15 +131,15 @@ int master_cleanup(int exitcode) {
        }
        already_cleaning_up = 1;
 
-       // Do system-dependent stuff
-       sysdep_master_cleanup();
+       // Close the sockets
+       context_cleanup();
 
        // Close the configuration system
        shutdown_config_system();
 
        // Close databases
        syslog(LOG_INFO, "citserver: closing databases");
-       close_databases();
+       cdb_close_databases();
 
        // If the operator requested a halt but not an exit, halt here.
        if (shutdown_and_halt) {
@@ -155,13 +156,12 @@ int master_cleanup(int exitcode) {
        fflush(stdout);
        fflush(stderr);
 
-       if (restart_server != 0) {
-               exitcode = 1;
-       }
-       else if ((running_as_daemon != 0) && ((exitcode == 0))) {
+       if ((running_as_daemon != 0) && ((exitcode == 0))) {
                exitcode = CTDLEXIT_SHUTDOWN;
        }
-       return (exitcode);
+
+       ctdl_lockfile(0);
+       exit(exitcode);
 }