Purge invalid LastRead records

This commit is contained in:
Michiel Broek 2007-08-26 10:44:11 +00:00
parent 6598c4202f
commit 9e63a9f9e9
2 changed files with 18 additions and 6 deletions

View File

@ -21,6 +21,8 @@ v0.91.10 21-Aug-2007
Added extra debug info in pack function. Added extra debug info in pack function.
Only adjust LR pointers if they must be changed to save some Only adjust LR pointers if they must be changed to save some
disk i/o. disk i/o.
LastRead records that don't belong to a valid user are
purged.
mbcico: mbcico:
Fixed a lot of compiler warnings. Fixed a lot of compiler warnings.

View File

@ -743,20 +743,30 @@ void JAM_Pack(void)
LR.HighReadMsg = jamHdrInfo.ActiveMsgs; LR.HighReadMsg = jamHdrInfo.ActiveMsgs;
Syslog('m', "JAM_Pack %s recno %d user %d HighRead is reset to %d", BaseName, i, LR.UserID, LR.HighReadMsg); Syslog('m', "JAM_Pack %s recno %d user %d HighRead is reset to %d", BaseName, i, LR.UserID, LR.HighReadMsg);
} }
Syslog('m', "JAM_Pack check user record %d", LR.UserID);
if (usrF) { if (usrF) {
Syslog('m', "JAM_Pack get user record %d at %d", LR.UserID, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID)); /*
* Search user record for LR pointer. If the record is valid and the
* user still exists then copy the LR record, else we drop it.
*/
fseek(usrF, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID), SEEK_SET); fseek(usrF, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID), SEEK_SET);
memset(&usr, 0, sizeof(usr)); memset(&usr, 0, sizeof(usr));
if (fread(&usr, usrhdr.recsize, 1, usrF) == 1) { if (fread(&usr, usrhdr.recsize, 1, usrF) == 1) {
mycrc = StringCRC32(tl(usr.sUserName)); mycrc = StringCRC32(tl(usr.sUserName));
Syslog('m', "JAM_Pack got user record %d \"%s\", crc %s", LR.UserID, usr.sUserName, if (mycrc == LR.UserCRC) {
(mycrc == LR.UserCRC) ? "Ok":"Error"); write(fdnJlr, &LR, sizeof(lastread));
} else {
Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
}
} else { } else {
Syslog('m', "JAM_Pack read error"); Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
} }
} else {
/*
* Should not be possible, but simply write LR records
* if no user data is available.
*/
write(fdnJlr, &LR, sizeof(lastread));
} }
write(fdnJlr, &LR, sizeof(lastread));
} }
} }
if (usrF) if (usrF)