#include "msgbase.h"
#include "user_ops.h"
#include "control.h"
-#include "serv_network.h" /* Needed for definition of UseTable */
#include "threads.h"
#include "context.h"
msg = CtdlFetchMessage(delnum, 0); /* dont need body */
if (msg != NULL) {
- xtime = atol(msg->cm_fields['T']);
+ xtime = atol(msg->cm_fields[eTimestamp]);
CtdlFreeMessage(msg);
} else {
xtime = 0L;
* Purge the use table of old entries.
*
*/
-int PurgeUseTable(void) {
+int PurgeUseTable(StrBuf *ErrMsg) {
int purged = 0;
struct cdbdata *cdbut;
struct UseTable ut;
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
- */
- memcpy(&ut, cdbut->ptr,
- ((cdbut->len > sizeof(struct UseTable)) ?
- sizeof(struct UseTable) : cdbut->len));
- cdb_free(cdbut);
+ /*
+ * 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
+ */
+ if (cdbut->len > sizeof(struct UseTable))
+ memcpy(&ut, cdbut->ptr, sizeof(struct UseTable));
+ else {
+ memset(&ut, 0, sizeof(struct UseTable));
+ memcpy(&ut, cdbut->ptr, cdbut->len);
+ }
+ cdb_free(cdbut);
if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN ) {
uptr = (struct UPurgeList *) malloc(sizeof(struct UPurgeList));
if (!server_shutting_down)
{
- retval = PurgeUseTable();
+ StrBuf *ErrMsg;
+
+ 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)
CtdlRegisterProtoHook(cmd_tdap, "TDAP", "Manually initiate auto-purger");
CtdlRegisterProtoHook(cmd_gpex, "GPEX", "Get expire policy");
CtdlRegisterProtoHook(cmd_spex, "SPEX", "Set expire policy");
- CtdlRegisterSessionHook(purge_databases, EVT_TIMER);
+ CtdlRegisterSessionHook(purge_databases, EVT_TIMER, PRIO_CLEANUP + 20);
}
/* return our module name for the log */