Skip to content
Browse files

fix code review comments.

  • Loading branch information...
1 parent 497299d commit 7f8305df0fe80f346ec9e6f5c47a34747e7b93a6 Robey Pointer committed Aug 23, 2010
Showing with 15 additions and 12 deletions.
  1. +6 −7 src/db.c
  2. +8 −5 src/redis.c
  3. +1 −0 src/redis.h
View
13 src/db.c
@@ -219,9 +219,7 @@ void randomkeyCommand(redisClient *c) {
static void addToReply(void *context, robj *keyobj) {
redisClient *c = (redisClient *)context;
- if (expireIfNeeded(c->db,keyobj) == 0) {
- addReplyBulk(c,keyobj);
- }
+ addReplyBulk(c,keyobj);
}
static void addToList(void *context, robj *keyobj) {
@@ -267,22 +265,23 @@ void keysCommand(redisClient *c) {
void keystolistCommand(redisClient *c) {
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;
if (lobj != NULL) {
if (lobj->type != REDIS_LIST) {
addReply(c,shared.wrongtypeerr);
return;
}
- dbDelete(c->db,c->argv[2]);
+ dbDelete(c->db,key);
}
lobj = createZiplistObject();
- dbAdd(c->db,c->argv[2],lobj);
+ dbAdd(c->db,key,lobj);
numkeys = scanKeys(c->db,pattern,addToList,lobj);
addReplyLongLong(c,numkeys);
- touchWatchedKey(c->db,c->argv[2]);
+ touchWatchedKey(c->db,key);
server.dirty++;
}
View
13 src/redis.c
@@ -1328,7 +1328,7 @@ void freeMemoryIfNeeded(void) {
if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue;
for (j = 0; j < server.dbnum; j++) {
int minttl = -1;
- robj *minkey = NULL;
+ sds minkey = NULL;
struct dictEntry *de;
if (dictSize(server.db[j].expires)) {
@@ -1346,10 +1346,11 @@ void freeMemoryIfNeeded(void) {
}
}
- dictDelete(server.db[j].expires,minkey);
- dictDelete(server.db[j].dict,minkey);
- server.db[j].expired_count++;
- server.db[j].prematurely_expired_count++;
+ if (dictDelete(server.db[j].expires,minkey) == DICT_OK &&
+ dictDelete(server.db[j].dict,minkey) == DICT_OK) {
+ server.db[j].expired_count++;
+ server.db[j].prematurely_expired_count++;
+ }
}
}
if (!freed) return; /* nothing to free... */
@@ -1547,6 +1548,8 @@ void setupSigTermAction(void) {
#else /* HAVE_BACKTRACE */
void setupSigSegvAction(void) {
}
+void setupSigTermAction(void) {
+}
#endif /* HAVE_BACKTRACE */
/* The End */
View
1 src/redis.h
@@ -685,6 +685,7 @@ void zslInsert(zskiplist *zsl, double score, robj *obj);
void freeMemoryIfNeeded(void);
int processCommand(redisClient *c);
void setupSigSegvAction(void);
+void setupSigTermAction(void);
struct redisCommand *lookupCommand(char *name);
void call(redisClient *c, struct redisCommand *cmd);
int prepareForShutdown();

0 comments on commit 7f8305d

Please sign in to comment.
Something went wrong with that request. Please try again.