X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/d08fac3eb9af712a4835773d7d6e58bdac465991..65b472acceaf1c359ae22a410fc608c5fb311ffa:/src/aof.c diff --git a/src/aof.c b/src/aof.c index f7a0c453..959a5f52 100644 --- a/src/aof.c +++ b/src/aof.c @@ -218,6 +218,7 @@ int loadAppendOnlyFile(char *filename) { FILE *fp = fopen(filename,"r"); struct redis_stat sb; int appendonly = server.appendonly; + long loops = 0; if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0) return REDIS_ERR; @@ -232,6 +233,8 @@ int loadAppendOnlyFile(char *filename) { server.appendonly = 0; fakeClient = createFakeClient(); + startLoading(fp); + while(1) { int argc, j; unsigned long len; @@ -241,6 +244,12 @@ int loadAppendOnlyFile(char *filename) { struct redisCommand *cmd; int force_swapout; + /* Serve the clients from time to time */ + if (!(loops++ % 1000)) { + loadingProgress(ftello(fp)); + aeProcessEvents(server.el, AE_FILE_EVENTS|AE_DONT_WAIT); + } + if (fgets(buf,sizeof(buf),fp) == NULL) { if (feof(fp)) break; @@ -266,9 +275,6 @@ int loadAppendOnlyFile(char *filename) { redisLog(REDIS_WARNING,"Unknown command '%s' reading the append only file", argv[0]->ptr); exit(1); } - /* Try object encoding */ - if (cmd->flags & REDIS_CMD_BULK) - argv[argc-1] = tryObjectEncoding(argv[argc-1]); /* Run the command in the context of a fake client */ fakeClient->argc = argc; fakeClient->argv = argv; @@ -300,6 +306,7 @@ int loadAppendOnlyFile(char *filename) { fclose(fp); freeFakeClient(fakeClient); server.appendonly = appendonly; + stopLoading(); return REDIS_OK; readerr: @@ -552,7 +559,8 @@ int rewriteAppendOnlyFileBackground(void) { char tmpfile[256]; if (server.vm_enabled) vmReopenSwapFile(); - close(server.fd); + if (server.ipfd > 0) close(server.ipfd); + if (server.sofd > 0) close(server.sofd); snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid()); if (rewriteAppendOnlyFile(tmpfile) == REDIS_OK) { _exit(0);