ddata.size = cdatalen;
ddata.data = cdata;
- /* Only compress Visit records. Everything else is uncompressed. */
- if (cdb == CDB_VISIT) {
+ /* Only compress Visit and UseTable records. Everything else is uncompressed. */
+ if ( (cdb == CDB_VISIT) || (cdb == CDB_USETABLE) ) {
compressing = 1;
zheader.magic = COMPRESS_MAGIC;
zheader.uncompressed_len = cdatalen;
}
}
-time_t CheckIfAlreadySeen(const char *Facility,
- StrBuf *guid,
- time_t now,
- time_t antiexpire,
- eCheckType cType,
- long ccid,
- long ioid)
+
+//time_t CheckIfAlreadySeen(const char *Facility,
+ //StrBuf *guid,
+ //time_t now,
+ //time_t antiexpire,
+ //eCheckType cType,
+ //long ccid,
+ //long ioid
+//) {
+
+
+time_t CheckIfAlreadySeen(StrBuf *guid, time_t now, time_t antiexpire, eCheckType cType)
{
time_t InDBTimeStamp = 0;
struct UseTable ut;
struct cdbdata *cdbut;
+ memset(&ut, 0, sizeof(struct UseTable)); // zeroing it out makes it compress better
+
if (cType != eWrite)
{
syslog(LOG_DEBUG, "Loading [%s]", ChrPtr(guid));
cdbut = cdb_fetch(CDB_USETABLE, SKEY(guid));
if ((cdbut != NULL) && (cdbut->ptr != NULL)) {
- memcpy(&ut, cdbut->ptr,
- ((cdbut->len > sizeof(struct UseTable)) ?
- sizeof(struct UseTable) : cdbut->len));
+ memcpy(&ut, cdbut->ptr, ((cdbut->len > sizeof(struct UseTable)) ? sizeof(struct UseTable) : cdbut->len));
InDBTimeStamp = now - ut.ut_timestamp;
if (InDBTimeStamp < antiexpire)
memcpy(ut.ut_msgid, SKEY(guid));
ut.ut_timestamp = now;
- syslog(LOG_DEBUG, "Saving new Timestamp");
/* rewrite the record anyway, to update the timestamp */
- cdb_store(CDB_USETABLE,
- SKEY(guid),
- &ut, sizeof(struct UseTable) );
-
- syslog(LOG_DEBUG, "Done Saving");
+ syslog(LOG_DEBUG, "(re)writing usetable record");
+ cdb_store(CDB_USETABLE, SKEY(guid), &ut, sizeof(struct UseTable));
return InDBTimeStamp;
}
eWrite /* write this to DB, unconditional. */
}eCheckType;
-time_t CheckIfAlreadySeen(const char *Facility,
- StrBuf *guid,
- time_t now,
- time_t antiexpire,
- eCheckType cType,
- long ccid,
- long ioid);
+//time_t CheckIfAlreadySeen(const char *Facility,
+ //StrBuf *guid,
+ //time_t now,
+ //time_t antiexpire,
+ //eCheckType cType,
+ //long ccid,
+ //long ioid);
+time_t CheckIfAlreadySeen(StrBuf *guid, time_t now, time_t antiexpire, eCheckType cType);
#endif /* DATABASE_H */
* This module handles shared rooms, inter-Citadel mail, and outbound
* mailing list processing.
*
- * Copyright (c) 2000-2016 by the citadel.org team
+ * Copyright (c) 2000-2017 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
}
}
now = time(NULL);
- if (CheckIfAlreadySeen("Networker Import",
- msgid,
- now, 0,
- eUpdate,
- CCC->cs_pid, 0) != 0)
- {
+ if (CheckIfAlreadySeen(msgid, now, 0, eUpdate)) {
FreeStrBuf(&msgid);
return(1);
}
RecvMsg->CurrMsg = (FetchItem*)vData;
- seenstamp = CheckIfAlreadySeen("POP3 Item Seen",
- RecvMsg->CurrMsg->MsgUID,
- EvGetNow(IO),
- EvGetNow(IO) - USETABLE_ANTIEXPIRE,
- eCheckUpdate,
- IO->ID, CCID);
+ seenstamp = CheckIfAlreadySeen(RecvMsg->CurrMsg->MsgUID,
+ EvGetNow(IO),
+ EvGetNow(IO) - USETABLE_ANTIEXPIRE,
+ eCheckUpdate
+ );
if (seenstamp != 0)
{
/* Item has already been seen */
SetPOP3State(IO, eStoreMsg);
syslog(LOG_DEBUG, "MARKING: %s as seen: ", ChrPtr(RecvMsg->CurrMsg->MsgUID));
- CheckIfAlreadySeen("POP3 Item Seen",
- RecvMsg->CurrMsg->MsgUID,
- EvGetNow(IO),
- EvGetNow(IO) - USETABLE_ANTIEXPIRE,
- eWrite,
- IO->ID, CCID
- );
+ CheckIfAlreadySeen(RecvMsg->CurrMsg->MsgUID, EvGetNow(IO), EvGetNow(IO) - USETABLE_ANTIEXPIRE, eWrite);
return DBQueueEventContext(&RecvMsg->IO, POP3_C_ReAttachToFetchMessages);
}
// check the use table
StrBuf *u = NewStrBuf();
StrBufAppendPrintf(u, "rss/%s", r->item_id);
- time_t already_seen = CheckIfAlreadySeen("rss", u, time(NULL), 604800, eUpdate, 0, 0);
+ time_t already_seen = CheckIfAlreadySeen(u, time(NULL), 604800, eUpdate);
FreeStrBuf(&u);
if (already_seen == 0) {
if (StrLength(guid) > 40)
StrBufCutAt(guid, 40, NULL);
- seenstamp = CheckIfAlreadySeen("FPAideMessage",
- guid,
- NOW,
- tsday,
- eUpdate,
- ccid,
- ioid);
+ seenstamp = CheckIfAlreadySeen(guid, NOW, tsday, eUpdate);
if ((seenstamp > 0) && (seenstamp < tsday))
{
FreeStrBuf(&guid);
/* yes, we did. flood protection kicks in. */
- syslog(LOG_DEBUG,
- "not sending message again - %ld < %ld \n", seenstamp, tsday);
+ syslog(LOG_DEBUG, "not sending message again - %ld < %ld \n", seenstamp, tsday);
return;
}
else
{
- syslog(LOG_DEBUG,
- "sending message. %ld >= %ld", seenstamp, tsday);
+ syslog(LOG_DEBUG, "sending message. %ld >= %ld", seenstamp, tsday);
FreeStrBuf(&guid);
/* no, this message isn't sent recently; go ahead. */
quickie_message(from,