* Discovered that my system hasn't processed its refcount_adjustments queue in about...
authorArt Cancro <ajc@citadel.org>
Thu, 4 Sep 2008 01:59:23 +0000 (01:59 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 4 Sep 2008 01:59:23 +0000 (01:59 +0000)
* When displaying ref count deltas to the log, show +1 instead of just 1 for increments.
* Added a new command TDAP which can be used by an Aide to manually initiate a run of The Dreaded Auto-Purger.

citadel/modules/expire/serv_expire.c
citadel/msgbase.c

index ab82d2828cfa9708d35276f7fcec957d8f1e269f..4d384a56cefc2356b46b4adecafeb1d95d4851a9 100644 (file)
@@ -121,10 +121,9 @@ int messages_purged;
 int users_not_purged;
 char *users_corrupt_msg = NULL;
 char *users_zero_msg = NULL;
-
 struct ctdlroomref *rr = NULL;
-
 extern struct CitContext *ContextList;
+int force_purge_now = 0;                       /* set to nonzero to force a run right now */
 
 
 /*
@@ -171,6 +170,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) {
                return;
        }
 
+
        /* If the room is set to expire by count, do that */
        if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
                if (num_msgs > epbuf.expire_value) {
@@ -856,7 +856,10 @@ void *purge_databases(void *args)
                  */
                 now = time(NULL);
                 localtime_r(&now, &tm);
-                if ((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200)) {
+                if (
+                       ((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200))
+                       && (force_purge_now == 0)
+               ) {
                         CtdlThreadSleep(60);
                         continue;
                 }
@@ -916,6 +919,7 @@ void *purge_databases(void *args)
                {
                        CtdlLogPrintf(CTDL_INFO, "Auto-purger: finished.\n");
                        last_purge = now;       /* So we don't do it again soon */
+                       force_purge_now = 0;
                }
                else
                        CtdlLogPrintf(CTDL_INFO, "Auto-purger: STOPPED.\n");
@@ -1005,6 +1009,14 @@ void cmd_fsck(char *argbuf) {
 }
 
 
+/*
+ * Manually initiate a run of The Dreaded Auto-Purger (tm)
+ */
+void cmd_tdap(char *argbuf) {
+       if (CtdlAccessCheck(ac_aide)) return;
+       force_purge_now = 1;
+       cprintf("%d Manually initiating a purger run now.\n", CIT_OK);
+}
 
 
 /*****************************************************************************/
@@ -1014,6 +1026,7 @@ CTDL_MODULE_INIT(expire)
        if (!threading)
        {
                CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts");
+               CtdlRegisterProtoHook(cmd_tdap, "TDAP", "Manually initiate auto-purger");
        }
        else
                CtdlThreadCreate("Auto Purger", CTDLTHREAD_BIGSTACK, purge_databases, NULL);
index 2324ee694b67dbd7f2c2c97230e20e8527711209..87a01d63cf8e7a583483ad34e03c314c9d4f2cbf 100644 (file)
@@ -4334,7 +4334,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
        struct arcq arcq_rec;
        int num_records_processed = 0;
 
-       snprintf(file_arcq_temp, sizeof file_arcq_temp, "%s2", file_arcq);
+       snprintf(file_arcq_temp, sizeof file_arcq_temp, "%s.%04x", file_arcq, rand());
 
        begin_critical_section(S_SUPPMSGMAIN);
        if (arcfp != NULL) {
@@ -4397,7 +4397,7 @@ void TDAP_AdjRefCount(long msgnum, int incr)
        smi.meta_refcount += incr;
        PutMetaData(&smi);
        end_critical_section(S_SUPPMSGMAIN);
-       CtdlLogPrintf(CTDL_DEBUG, "msg %ld ref count delta %d, is now %d\n",
+       CtdlLogPrintf(CTDL_DEBUG, "msg %ld ref count delta %+d, is now %d\n",
                msgnum, incr, smi.meta_refcount);
 
        /* If the reference count is now zero, delete the message