X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fdatabase.c;h=3f5123f0189b7ed2334fff56b92ce7d2cf096e71;hb=1493fd8ff0de73d30336607b43b1c8113ffcffa2;hp=3bab5776d90ebe522eefb34b1c751f631de98ca1;hpb=66f09fdd7c3f58e13ed01431dd5148302327ca6e;p=citadel.git diff --git a/citadel/database.c b/citadel/database.c index 3bab5776d..3f5123f01 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -27,16 +27,8 @@ /*****************************************************************************/ #include "sysdep.h" -#include -#include #include -#include -#include -#include -#include -#include #include -#include #include #ifdef HAVE_DB_H @@ -54,17 +46,10 @@ #include -#include "citadel.h" -#include "server.h" -#include "citserver.h" -#include "database.h" -#include "msgbase.h" -#include "sysdep_decls.h" -#include "threads.h" -#include "config.h" -#include "control.h" #include "ctdl_module.h" +#include "control.h" +#include "citserver.h" static DB *dbp[MAXCDB]; /* One DB handle for each Citadel database */ @@ -97,8 +82,10 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg) /* Verbose logging callback */ void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg) { + int *FOO = NULL; syslog(LOG_ALERT, "DB: %s", msg); cit_backtrace(); + *FOO = 1; } @@ -183,7 +170,7 @@ void cdb_check_handles(void) /* * Cull the database logs */ -static void cdb_cull_logs(void) +void cdb_cull_logs(void) { u_int32_t flags; int ret; @@ -219,15 +206,6 @@ static void cdb_cull_logs(void) } } -/* - * Manually initiate log file cull. - */ -void cmd_cull(char *argbuf) { - if (CtdlAccessCheck(ac_internal)) return; - cdb_cull_logs(); - cprintf("%d Database log file cull completed.\n", CIT_OK); -} - /* * Request a checkpoint of the database. Called once per minute by the thread manager. @@ -435,7 +413,6 @@ void cdb_chmod_data(void) { } syslog(LOG_DEBUG, "open_databases() finished\n"); - CtdlRegisterProtoHook(cmd_cull, "CULL", "Cull database logs"); } @@ -912,8 +889,8 @@ int SeentDebugEnabled = 0; #define DBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (SeentDebugEnabled != 0)) #define SEENM_syslog(LEVEL, FORMAT) \ DBGLOG(LEVEL) syslog(LEVEL, \ - "IO[%ld]CC[%ld] SEEN[%s][%d] " FORMAT, \ - ioid, ccid, Facility, cType) + "%s[%ld]CC[%ld] SEEN[%s][%d] " FORMAT, \ + IOSTR, ioid, ccid, Facility, cType) time_t CheckIfAlreadySeen(const char *Facility, StrBuf *guid, @@ -923,24 +900,25 @@ time_t CheckIfAlreadySeen(const char *Facility, long ccid, long ioid) { + time_t InDBTimeStamp = 0; struct UseTable ut; struct cdbdata *cdbut; if (cType != eWrite) { - time_t InDBTimeStamp = 0; SEENM_syslog(LOG_DEBUG, "Loading"); cdbut = cdb_fetch(CDB_USETABLE, SKEY(guid)); - if (cdbut != NULL) { + if ((cdbut != NULL) && (cdbut->ptr != NULL)) { memcpy(&ut, cdbut->ptr, ((cdbut->len > sizeof(struct UseTable)) ? sizeof(struct UseTable) : cdbut->len)); - - if (ut.ut_timestamp > antiexpire) + InDBTimeStamp = ut.ut_timestamp; + + if (InDBTimeStamp < antiexpire) { SEENM_syslog(LOG_DEBUG, "Found - Not expired."); cdb_free(cdbut); - return ut.ut_timestamp; + return InDBTimeStamp; } else { @@ -951,6 +929,8 @@ time_t CheckIfAlreadySeen(const char *Facility, } else { + if (cdbut) cdb_free(cdbut); + SEENM_syslog(LOG_DEBUG, "not Found"); } @@ -968,7 +948,7 @@ time_t CheckIfAlreadySeen(const char *Facility, &ut, sizeof(struct UseTable) ); SEENM_syslog(LOG_DEBUG, "Done Saving"); - return 0; + return InDBTimeStamp; }