]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/expire/serv_expire.c
Prepared some of the authmode stuff for the imminent addition
[citadel.git] / citadel / modules / expire / serv_expire.c
index d856761c8657991d6d9081f26f0886bd55bb8963..eaff4280b9831e6ebcb1da5efc345e70180a0bc0 100644 (file)
@@ -62,7 +62,7 @@
 #include "user_ops.h"
 #include "control.h"
 #include "serv_network.h"      /* Needed for defenition of UseTable */
-
+#include "threads.h"
 
 #include "ctdl_module.h"
 
@@ -460,15 +460,18 @@ int PurgeUsers(void) {
        lprintf(CTDL_DEBUG, "PurgeUsers() called\n");
        users_not_purged = 0;
 
-       if (config.c_auth_mode == 1) {
-               /* host auth mode */
-               ForEachUser(do_uid_user_purge, NULL);
-       }
-       else {
-               /* native auth mode */
-               if (config.c_userpurge > 0) {
-                       ForEachUser(do_user_purge, NULL);
-               }
+       switch(config.c_auth_mode) {
+               case AUTHMODE_NATIVE:
+                       if (config.c_userpurge > 0) {
+                               ForEachUser(do_user_purge, NULL);
+                       }
+                       break;
+               case AUTHMODE_HOST:
+                       ForEachUser(do_uid_user_purge, NULL);
+                       break;
+               default:
+                       lprintf(CTDL_DEBUG, "Unknown authentication mode!\n");
+                       break;
        }
 
        transcript = malloc(SIZ);
@@ -720,11 +723,7 @@ void *purge_databases(void *args)
         time_t now;
         struct tm tm;
 
-        CT_PUSH();     // Makes it easier to access this threads structure
-
-        cdb_allocate_tsd();
-
-        while (!CtdlThreadCheckStop(CT)) {
+        while (!CtdlThreadCheckStop()) {
                 /* Do the auto-purge if the current hour equals the purge hour,
                  * but not if the operation has already been performed in the
                  * last twelve hours.  This is usually enough granularity.
@@ -739,49 +738,49 @@ void *purge_databases(void *args)
 
                 lprintf(CTDL_INFO, "Auto-purger: starting.\n");
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUsers();
                        lprintf(CTDL_NOTICE, "Purged %d users.\n", retval);
                }
                
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        PurgeMessages();
                        lprintf(CTDL_NOTICE, "Expired %d messages.\n", messages_purged);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = PurgeRooms();
                        lprintf(CTDL_NOTICE, "Expired %d rooms.\n", retval);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = PurgeVisits();
                        lprintf(CTDL_NOTICE, "Purged %d visits.\n", retval);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUseTable();
                        lprintf(CTDL_NOTICE, "Purged %d entries from the use table.\n", retval);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = PurgeEuidIndexTable();
                        lprintf(CTDL_NOTICE, "Purged %d entries from the EUID index.\n", retval);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        retval = TDAP_ProcessAdjRefCountQueue();
                        lprintf(CTDL_NOTICE, "Processed %d message reference count adjustments.\n", retval);
                }
 
-               if (!CtdlThreadCheckStop(CT))
+               if (!CtdlThreadCheckStop())
                {
                        lprintf(CTDL_INFO, "Auto-purger: finished.\n");
                        last_purge = now;       /* So we don't do it again soon */