Fixed issues with expire introduced with latest millisecond resolution feature. Many time_t were not converted to long long, and one time() call was not replaced with mstime().

This commit is contained in:
antirez 2011-11-12 01:04:27 +01:00
parent 3570629f90
commit 4be855e757
4 changed files with 7 additions and 7 deletions

View File

@ -431,7 +431,7 @@ int rewriteAppendOnlyFile(char *filename) {
FILE *fp; FILE *fp;
char tmpfile[256]; char tmpfile[256];
int j; int j;
time_t now = time(NULL); long long now = mstime();
/* Note that we have to use a different temp name here compared to the /* Note that we have to use a different temp name here compared to the
* one used by rewriteAppendOnlyFileBackground() function. */ * one used by rewriteAppendOnlyFileBackground() function. */
@ -462,7 +462,7 @@ int rewriteAppendOnlyFile(char *filename) {
while((de = dictNext(di)) != NULL) { while((de = dictNext(di)) != NULL) {
sds keystr; sds keystr;
robj key, *o; robj key, *o;
time_t expiretime; long long expiretime;
keystr = dictGetKey(de); keystr = dictGetKey(de);
o = dictGetVal(de); o = dictGetVal(de);

View File

@ -91,7 +91,7 @@ void computeDatasetDigest(unsigned char *final) {
while((de = dictNext(di)) != NULL) { while((de = dictNext(di)) != NULL) {
sds key; sds key;
robj *keyobj, *o; robj *keyobj, *o;
time_t expiretime; long long expiretime;
memset(digest,0,20); /* This key-val digest */ memset(digest,0,20); /* This key-val digest */
key = dictGetKey(de); key = dictGetKey(de);

View File

@ -597,7 +597,7 @@ int rdbSave(char *filename) {
dictEntry *de; dictEntry *de;
char tmpfile[256]; char tmpfile[256];
int j; int j;
time_t now = mstime(); long long now = mstime();
FILE *fp; FILE *fp;
rio rdb; rio rdb;

View File

@ -562,17 +562,17 @@ void activeExpireCycle(void) {
* of the keys were expired. */ * of the keys were expired. */
do { do {
long num = dictSize(db->expires); long num = dictSize(db->expires);
time_t now = time(NULL); long long now = mstime();
expired = 0; expired = 0;
if (num > REDIS_EXPIRELOOKUPS_PER_CRON) if (num > REDIS_EXPIRELOOKUPS_PER_CRON)
num = REDIS_EXPIRELOOKUPS_PER_CRON; num = REDIS_EXPIRELOOKUPS_PER_CRON;
while (num--) { while (num--) {
dictEntry *de; dictEntry *de;
time_t t; long long t;
if ((de = dictGetRandomKey(db->expires)) == NULL) break; if ((de = dictGetRandomKey(db->expires)) == NULL) break;
t = (time_t) dictGetVal(de); t = dictGetSignedIntegerVal(de);
if (now > t) { if (now > t) {
sds key = dictGetKey(de); sds key = dictGetKey(de);
robj *keyobj = createStringObject(key,sdslen(key)); robj *keyobj = createStringObject(key,sdslen(key));