X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fexpire%2Fserv_expire.c;h=4d384a56cefc2356b46b4adecafeb1d95d4851a9;hb=a81ad4c588e3c0318af73c61f94567cf3f4b87ac;hp=ab82d2828cfa9708d35276f7fcec957d8f1e269f;hpb=7d48a403f792b4b0fb82e64d9f57a90fbc1b1933;p=citadel.git 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);