summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aof.c21
-rw-r--r--src/networking.c13
-rw-r--r--src/server.c6
-rw-r--r--tests/unit/expire.tcl10
4 files changed, 36 insertions, 14 deletions
diff --git a/src/aof.c b/src/aof.c
index 02409abe6..6f8e53712 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -611,19 +611,24 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
} else if (cmd->proc == setCommand && argc > 3) {
int i;
robj *exarg = NULL, *pxarg = NULL;
- /* Translate SET [EX seconds][PX milliseconds] to SET and PEXPIREAT */
- buf = catAppendOnlyGenericCommand(buf,3,argv);
for (i = 3; i < argc; i ++) {
if (!strcasecmp(argv[i]->ptr, "ex")) exarg = argv[i+1];
if (!strcasecmp(argv[i]->ptr, "px")) pxarg = argv[i+1];
}
serverAssert(!(exarg && pxarg));
- if (exarg)
- buf = catAppendOnlyExpireAtCommand(buf,server.expireCommand,argv[1],
- exarg);
- if (pxarg)
- buf = catAppendOnlyExpireAtCommand(buf,server.pexpireCommand,argv[1],
- pxarg);
+
+ if (exarg || pxarg) {
+ /* Translate SET [EX seconds][PX milliseconds] to SET and PEXPIREAT */
+ buf = catAppendOnlyGenericCommand(buf,3,argv);
+ if (exarg)
+ buf = catAppendOnlyExpireAtCommand(buf,server.expireCommand,argv[1],
+ exarg);
+ if (pxarg)
+ buf = catAppendOnlyExpireAtCommand(buf,server.pexpireCommand,argv[1],
+ pxarg);
+ } else {
+ buf = catAppendOnlyGenericCommand(buf,argc,argv);
+ }
} else {
/* All the other commands don't need translation or need the
* same translation already operated in the command vector
diff --git a/src/networking.c b/src/networking.c
index 8d3e057b7..80973109c 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1019,7 +1019,6 @@ void disconnectSlaves(void) {
listNode *ln;
listRewind(server.slaves,&li);
while((ln = listNext(&li))) {
- listNode *ln = listFirst(server.slaves);
freeClient((client*)ln->value);
}
}
@@ -1239,14 +1238,20 @@ void freeClientAsync(client *c) {
/* Free the clietns marked as CLOSE_ASAP, return the number of clients
* freed. */
int freeClientsInAsyncFreeQueue(void) {
- int freed = listLength(server.clients_to_close);
- while (listLength(server.clients_to_close)) {
- listNode *ln = listFirst(server.clients_to_close);
+ int freed = 0;
+ listIter li;
+ listNode *ln;
+
+ listRewind(server.clients_to_close,&li);
+ while ((ln = listNext(&li)) != NULL) {
client *c = listNodeValue(ln);
+ if (c->flags & CLIENT_PROTECTED) continue;
+
c->flags &= ~CLIENT_CLOSE_ASAP;
freeClient(c);
listDelNode(server.clients_to_close,ln);
+ freed++;
}
return freed;
}
diff --git a/src/server.c b/src/server.c
index b7a6a928f..e8e711240 100644
--- a/src/server.c
+++ b/src/server.c
@@ -776,11 +776,11 @@ struct redisCommand redisCommandTable[] = {
0,NULL,0,0,0,0,0,0},
{"watch",watchCommand,-2,
- "no-script fast @transaction",
+ "no-script fast ok-loading ok-stale @transaction",
0,NULL,1,-1,1,0,0,0},
{"unwatch",unwatchCommand,1,
- "no-script fast @transaction",
+ "no-script fast ok-loading ok-stale @transaction",
0,NULL,0,0,0,0,0,0},
{"cluster",clusterCommand,-2,
@@ -3627,6 +3627,8 @@ int processCommand(client *c) {
c->cmd->proc != multiCommand &&
c->cmd->proc != execCommand &&
c->cmd->proc != discardCommand &&
+ c->cmd->proc != watchCommand &&
+ c->cmd->proc != unwatchCommand &&
!(c->cmd->proc == shutdownCommand &&
c->argc == 2 &&
tolower(((char*)c->argv[1]->ptr)[0]) == 'n') &&
diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl
index 11fb82ef0..52d174d75 100644
--- a/tests/unit/expire.tcl
+++ b/tests/unit/expire.tcl
@@ -232,4 +232,14 @@ start_server {tags {"expire"}} {
set ttl [r ttl foo]
assert {$ttl <= 100 && $ttl > 90}
}
+
+ test {SET - use KEEPTTL option, TTL should not be removed after loadaof} {
+ r config set appendonly yes
+ r set foo bar EX 100
+ r set foo bar2 KEEPTTL
+ after 2000
+ r debug loadaof
+ set ttl [r ttl foo]
+ assert {$ttl <= 98 && $ttl > 90}
+ }
}