From: Art Cancro Date: Thu, 4 Sep 2008 01:59:23 +0000 (+0000) Subject: * Discovered that my system hasn't processed its refcount_adjustments queue in about... X-Git-Tag: v7.86~1971 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=a81ad4c588e3c0318af73c61f94567cf3f4b87ac * Discovered that my system hasn't processed its refcount_adjustments queue in about six months, because a file called refcount_adjustments.dat2 was sitting around and keeping the link() command from succeeding. Fortunately, the code is robust enough to gracefully excuse itself from this situation without corrupting the database, but now I've got a six month backlog of refcount adjustments to process. Corrected this situation for anyone else who is having it, by putting a random number in the name of the temporary file. * 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. --- diff --git a/citadel/modules/expire/serv_expire.c b/citadel/modules/expire/serv_expire.c index ab82d2828..4d384a56c 100644 --- a/citadel/modules/expire/serv_expire.c +++ b/citadel/modules/expire/serv_expire.c @@ -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); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 2324ee694..87a01d63c 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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