AdjRefCount() now runs synchronously, eliminating the refcount_adjustments.dat queue...
[citadel.git] / citadel / modules / expire / serv_expire.c
index 7fd28e6b4a699217d90d094fc8f8ee6ac9866ee1..879975496dc942626a31e90c2692c82e4afe71ce 100644 (file)
@@ -3,7 +3,7 @@
  *
  * You might also see this module affectionately referred to as the DAP (the Dreaded Auto-Purger).
  *
- * Copyright (c) 1988-2017 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
@@ -786,9 +786,9 @@ int PurgeEuidIndexTable(void) {
 
 
 /*
- * 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;
@@ -804,8 +804,8 @@ int PurgeStaleOpenIDassociations(void) {
        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) {
@@ -821,8 +821,8 @@ int PurgeStaleOpenIDassociations(void) {
        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;
        }
@@ -883,7 +883,6 @@ void purge_databases(void)
                ErrMsg = NewStrBuf ();
                retval = PurgeUseTable(ErrMsg);
                        syslog(LOG_NOTICE, "Purged %d entries from the use table.", retval);
-////TODO: fix errmsg
                FreeStrBuf(&ErrMsg);
        }
 
@@ -895,27 +894,24 @@ void purge_databases(void)
 
        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
        }
 
-       // Enable this after we've tested it and make it a site-configurable option.
-       // This will allow the database files to shrink when they can.
-       // if (!server_shutting_down)
-       // {
-               // cdb_compact();
-       // }
-
        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 {