*
* You might also see this module affectionately referred to as the DAP (the Dreaded Auto-Purger).
*
- * Copyright (c) 1988-2015 by citadel.org (Art Cancro, Wilifried Goesgens, and others)
+ * Copyright (c) 1988-2018 by citadel.org (Art Cancro, Wilifried Goesgens, and others)
*
* This program is open source software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
long vu_usernum;
};
-
struct ctdlroomref {
struct ctdlroomref *next;
long msgnum;
return;
}
-
/* If the room is set to expire by count, do that */
if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
if (num_msgs > epbuf.expire_value) {
}
-
int PurgeRooms(void) {
struct PurgeList *pptr;
int num_rooms_purged = 0;
syslog(LOG_DEBUG, "PurgeRooms() called");
-
/* Load up a table full of valid user numbers so we can delete
* user-owned rooms for users who no longer exist */
ForEachUser(AddValidUser, NULL);
ValidUserList = vuptr;
}
-
transcript = malloc(SIZ);
strcpy(transcript, "The following rooms have been auto-purged:\n");
}
-
-
/*
* Back end function to check user accounts for expiration.
*/
}
-
int PurgeUsers(void) {
struct PurgeList *pptr;
int num_users_purged = 0;
return(purged);
}
+
/*
* Purge the use table of old entries.
*
struct UPurgeList *uptr;
/* Phase 1: traverse through the table, discovering old records... */
- if (CheckTDAPVeto(CDB_USETABLE, ErrMsg))
- {
- syslog(LOG_DEBUG, "Purge use table: VETO!");
- return 0;
- }
syslog(LOG_DEBUG, "Purge use table: phase 1");
cdb_rewind(CDB_USETABLE);
- while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
-
- /*
- * TODODRW: change this to create a new function time_t cdb_get_timestamp( struct cdbdata *)
- * this will release this file from the serv_network.h
- * Maybe it could be a macro that extracts and casts the reult
- */
+ while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL)
+ {
if (cdbut->len > sizeof(struct UseTable))
memcpy(&ut, cdbut->ptr, sizeof(struct UseTable));
- else {
+ else
+ {
memset(&ut, 0, sizeof(struct UseTable));
memcpy(&ut, cdbut->ptr, cdbut->len);
}
cdb_free(cdbut);
- if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN ) {
+ if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN )
+ {
uptr = (struct UPurgeList *) malloc(sizeof(struct UPurgeList));
- if (uptr != NULL) {
+ if (uptr != NULL)
+ {
uptr->next = ul;
safestrncpy(uptr->up_key, ut.ut_msgid, sizeof uptr->up_key);
ul = uptr;
}
-
/*
* Purge the EUID Index of old records.
*
}
-
/*
- * Purge OpenID assocations for missing users (theoretically this will never delete anything)
+ * Purge external auth assocations for missing users (theoretically this will never delete anything)
*/
-int PurgeStaleOpenIDassociations(void) {
+int PurgeStaleExtAuthAssociations(void) {
struct cdbdata *cdboi;
struct ctdluser usbuf;
HashList *keys = NULL;
if (!keys) return(0);
- cdb_rewind(CDB_OPENID);
- while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
+ cdb_rewind(CDB_EXTAUTH);
+ while (cdboi = cdb_next_item(CDB_EXTAUTH), cdboi != NULL) {
if (cdboi->len > sizeof(long)) {
memcpy(&usernum, cdboi->ptr, sizeof(long));
if (CtdlGetUserByNumber(&usbuf, usernum) != 0) {
HashPos = GetNewHashPos(keys, 0);
while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
{
- syslog(LOG_DEBUG, "Deleting associated OpenID <%s>", (char*)Value);
- cdb_delete(CDB_OPENID, Value, strlen(Value));
+ syslog(LOG_DEBUG, "Deleting associated external authenticator <%s>", (char*)Value);
+ cdb_delete(CDB_EXTAUTH, Value, strlen(Value));
/* note: don't free(Value) -- deleting the hash list will handle this for us */
++num_deleted;
}
}
-
-
-
void purge_databases(void)
{
int retval;
ErrMsg = NewStrBuf ();
retval = PurgeUseTable(ErrMsg);
syslog(LOG_NOTICE, "Purged %d entries from the use table.", retval);
-////TODO: fix errmsg
FreeStrBuf(&ErrMsg);
}
if (!server_shutting_down)
{
- retval = PurgeStaleOpenIDassociations();
- syslog(LOG_NOTICE, "Purged %d stale OpenID associations.", retval);
+ retval = PurgeStaleExtAuthAssociations();
+ syslog(LOG_NOTICE, "Purged %d stale external auth associations.", retval);
}
- if (!server_shutting_down)
+ //if (!server_shutting_down)
+ //{
+ // FIXME this is where we could do a non-interactive delete of zero-refcount messages
+ //}
+
+ if ( (!server_shutting_down) && (CtdlGetConfigInt("c_shrink_db_files") != 0) )
{
- retval = TDAP_ProcessAdjRefCountQueue();
- syslog(LOG_NOTICE, "Processed %d message reference count adjustments.", retval);
+ cdb_compact(); // Shrink the DB files on disk
}
if (!server_shutting_down)
{
syslog(LOG_INFO, "Auto-purger: finished.");
- last_purge = now; /* So we don't do it again soon */
+ last_purge = now; // So we don't do it again soon
force_purge_now = 0;
}
else {
}
-
CTDL_MODULE_INIT(expire)
{
if (!threading)