提交 7f8305df 编写于 作者: R Robey Pointer

fix code review comments.

上级 497299df
...@@ -219,9 +219,7 @@ void randomkeyCommand(redisClient *c) { ...@@ -219,9 +219,7 @@ void randomkeyCommand(redisClient *c) {
static void addToReply(void *context, robj *keyobj) { static void addToReply(void *context, robj *keyobj) {
redisClient *c = (redisClient *)context; redisClient *c = (redisClient *)context;
if (expireIfNeeded(c->db,keyobj) == 0) { addReplyBulk(c,keyobj);
addReplyBulk(c,keyobj);
}
} }
static void addToList(void *context, robj *keyobj) { static void addToList(void *context, robj *keyobj) {
...@@ -267,7 +265,8 @@ void keysCommand(redisClient *c) { ...@@ -267,7 +265,8 @@ void keysCommand(redisClient *c) {
void keystolistCommand(redisClient *c) { void keystolistCommand(redisClient *c) {
sds pattern = c->argv[1]->ptr; sds pattern = c->argv[1]->ptr;
robj *lobj = lookupKeyWrite(c->db,c->argv[2]); robj *key = c->argv[2];
robj *lobj = lookupKeyWrite(c->db,key);
unsigned long numkeys; unsigned long numkeys;
if (lobj != NULL) { if (lobj != NULL) {
...@@ -275,14 +274,14 @@ void keystolistCommand(redisClient *c) { ...@@ -275,14 +274,14 @@ void keystolistCommand(redisClient *c) {
addReply(c,shared.wrongtypeerr); addReply(c,shared.wrongtypeerr);
return; return;
} }
dbDelete(c->db,c->argv[2]); dbDelete(c->db,key);
} }
lobj = createZiplistObject(); lobj = createZiplistObject();
dbAdd(c->db,c->argv[2],lobj); dbAdd(c->db,key,lobj);
numkeys = scanKeys(c->db,pattern,addToList,lobj); numkeys = scanKeys(c->db,pattern,addToList,lobj);
addReplyLongLong(c,numkeys); addReplyLongLong(c,numkeys);
touchWatchedKey(c->db,c->argv[2]); touchWatchedKey(c->db,key);
server.dirty++; server.dirty++;
} }
......
...@@ -1328,7 +1328,7 @@ void freeMemoryIfNeeded(void) { ...@@ -1328,7 +1328,7 @@ void freeMemoryIfNeeded(void) {
if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue; if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue;
for (j = 0; j < server.dbnum; j++) { for (j = 0; j < server.dbnum; j++) {
int minttl = -1; int minttl = -1;
robj *minkey = NULL; sds minkey = NULL;
struct dictEntry *de; struct dictEntry *de;
if (dictSize(server.db[j].expires)) { if (dictSize(server.db[j].expires)) {
...@@ -1346,10 +1346,11 @@ void freeMemoryIfNeeded(void) { ...@@ -1346,10 +1346,11 @@ void freeMemoryIfNeeded(void) {
} }
} }
dictDelete(server.db[j].expires,minkey); if (dictDelete(server.db[j].expires,minkey) == DICT_OK &&
dictDelete(server.db[j].dict,minkey); dictDelete(server.db[j].dict,minkey) == DICT_OK) {
server.db[j].expired_count++; server.db[j].expired_count++;
server.db[j].prematurely_expired_count++; server.db[j].prematurely_expired_count++;
}
} }
} }
if (!freed) return; /* nothing to free... */ if (!freed) return; /* nothing to free... */
...@@ -1547,6 +1548,8 @@ void setupSigTermAction(void) { ...@@ -1547,6 +1548,8 @@ void setupSigTermAction(void) {
#else /* HAVE_BACKTRACE */ #else /* HAVE_BACKTRACE */
void setupSigSegvAction(void) { void setupSigSegvAction(void) {
} }
void setupSigTermAction(void) {
}
#endif /* HAVE_BACKTRACE */ #endif /* HAVE_BACKTRACE */
/* The End */ /* The End */
...@@ -685,6 +685,7 @@ void zslInsert(zskiplist *zsl, double score, robj *obj); ...@@ -685,6 +685,7 @@ void zslInsert(zskiplist *zsl, double score, robj *obj);
void freeMemoryIfNeeded(void); void freeMemoryIfNeeded(void);
int processCommand(redisClient *c); int processCommand(redisClient *c);
void setupSigSegvAction(void); void setupSigSegvAction(void);
void setupSigTermAction(void);
struct redisCommand *lookupCommand(char *name); struct redisCommand *lookupCommand(char *name);
void call(redisClient *c, struct redisCommand *cmd); void call(redisClient *c, struct redisCommand *cmd);
int prepareForShutdown(); int prepareForShutdown();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册