]> git.saurik.com Git - redis.git/blobdiff - src/db.c
AOF refactoring, now with three states: ON, OFF, WAIT_REWRITE.
[redis.git] / src / db.c
index 38983cb5a9d66ce331ee9226ef967ec6e83412fc..616b1fa1f3ad4d40e357769be8cc2191c0c15c13 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -328,8 +328,22 @@ void typeCommand(redisClient *c) {
 }
 
 void shutdownCommand(redisClient *c) {
-    if (prepareForShutdown() == REDIS_OK)
-        exit(0);
+    int flags = 0;
+
+    if (c->argc > 2) {
+        addReply(c,shared.syntaxerr);
+        return;
+    } else if (c->argc == 2) {
+        if (!strcasecmp(c->argv[1]->ptr,"nosave")) {
+            flags |= REDIS_SHUTDOWN_NOSAVE;
+        } else if (!strcasecmp(c->argv[1]->ptr,"save")) {
+            flags |= REDIS_SHUTDOWN_SAVE;
+        } else {
+            addReply(c,shared.syntaxerr);
+            return;
+        }
+    }
+    if (prepareForShutdown(flags) == REDIS_OK) exit(0);
     addReplyError(c,"Errors trying to SHUTDOWN. Check logs.");
 }
 
@@ -473,7 +487,7 @@ void propagateExpire(redisDb *db, robj *key) {
     argv[1] = key;
     incrRefCount(key);
 
-    if (server.appendonly)
+    if (server.aof_state != REDIS_AOF_OFF)
         feedAppendOnlyFile(server.delCommand,db->id,argv,2);
     if (listLength(server.slaves))
         replicationFeedSlaves(server.slaves,db->id,argv,2);