From: antirez Date: Sat, 12 Nov 2011 00:04:27 +0000 (+0100) Subject: Fixed issues with expire introduced with latest millisecond resolution feature. Many... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/4be855e757b800a9f848823fcee8b7faf3e1eba0?ds=sidebyside 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(). --- diff --git a/src/aof.c b/src/aof.c index 8f3f5d59..4a463bde 100644 --- a/src/aof.c +++ b/src/aof.c @@ -431,7 +431,7 @@ int rewriteAppendOnlyFile(char *filename) { FILE *fp; char tmpfile[256]; 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 * one used by rewriteAppendOnlyFileBackground() function. */ @@ -462,7 +462,7 @@ int rewriteAppendOnlyFile(char *filename) { while((de = dictNext(di)) != NULL) { sds keystr; robj key, *o; - time_t expiretime; + long long expiretime; keystr = dictGetKey(de); o = dictGetVal(de); diff --git a/src/debug.c b/src/debug.c index 2dfe2280..376e0712 100644 --- a/src/debug.c +++ b/src/debug.c @@ -91,7 +91,7 @@ void computeDatasetDigest(unsigned char *final) { while((de = dictNext(di)) != NULL) { sds key; robj *keyobj, *o; - time_t expiretime; + long long expiretime; memset(digest,0,20); /* This key-val digest */ key = dictGetKey(de); diff --git a/src/rdb.c b/src/rdb.c index e11f5c9c..2c0feb6d 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -597,7 +597,7 @@ int rdbSave(char *filename) { dictEntry *de; char tmpfile[256]; int j; - time_t now = mstime(); + long long now = mstime(); FILE *fp; rio rdb; diff --git a/src/redis.c b/src/redis.c index 7d209439..23b7b280 100644 --- a/src/redis.c +++ b/src/redis.c @@ -562,17 +562,17 @@ void activeExpireCycle(void) { * of the keys were expired. */ do { long num = dictSize(db->expires); - time_t now = time(NULL); + long long now = mstime(); expired = 0; if (num > REDIS_EXPIRELOOKUPS_PER_CRON) num = REDIS_EXPIRELOOKUPS_PER_CRON; while (num--) { dictEntry *de; - time_t t; + long long t; if ((de = dictGetRandomKey(db->expires)) == NULL) break; - t = (time_t) dictGetVal(de); + t = dictGetSignedIntegerVal(de); if (now > t) { sds key = dictGetKey(de); robj *keyobj = createStringObject(key,sdslen(key));