X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/6eaad66373982aa9c1c0ff6b584c542670548d0e..e53ca04b50b86ef158a75c54ae9ee8b17e31719c:/src/aof.c diff --git a/src/aof.c b/src/aof.c index f5d04a62..8ce6cd12 100644 --- a/src/aof.c +++ b/src/aof.c @@ -220,8 +220,10 @@ int loadAppendOnlyFile(char *filename) { int appendonly = server.appendonly; long loops = 0; - if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0) + if (fp && redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0) { + fclose(fp); return REDIS_ERR; + } if (fp == NULL) { redisLog(REDIS_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno)); @@ -529,7 +531,10 @@ int rewriteAppendOnlyFileBackground(void) { pid_t childpid; if (server.bgrewritechildpid != -1) return REDIS_ERR; - redisAssert(server.ds_enabled == 0); + if (server.ds_enabled != 0) { + redisLog(REDIS_WARNING,"BGREWRITEAOF called with diskstore enabled: AOF is not supported when diskstore is enabled. Operation not performed."); + return REDIS_ERR; + } if ((childpid = fork()) == 0) { /* Child */ char tmpfile[256]; @@ -585,10 +590,7 @@ void aofRemoveTempFile(pid_t childpid) { /* A background append only file rewriting (BGREWRITEAOF) terminated its work. * Handle this. */ -void backgroundRewriteDoneHandler(int statloc) { - int exitcode = WEXITSTATUS(statloc); - int bysignal = WIFSIGNALED(statloc); - +void backgroundRewriteDoneHandler(int exitcode, int bysignal) { if (!bysignal && exitcode == 0) { int fd; char tmpfile[256]; @@ -636,7 +638,7 @@ void backgroundRewriteDoneHandler(int statloc) { } else { redisLog(REDIS_WARNING, "Background append only file rewriting terminated by signal %d", - WTERMSIG(statloc)); + bysignal); } cleanup: sdsfree(server.bgrewritebuf);