From 4178a80282ac917a48771da2c2d1ee65bc562161 Mon Sep 17 00:00:00 2001 From: Damian Janowski Date: Tue, 12 Mar 2013 14:37:50 -0300 Subject: [PATCH] Abort when opening the RDB file results in an error other than ENOENT. This fixes cases where the RDB file does exist but can't be accessed for any reason. For instance, when the Redis process doesn't have enough permissions on the file. --- src/rdb.c | 1 - src/redis.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rdb.c b/src/rdb.c index afa9676b..fcd912d7 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1069,7 +1069,6 @@ int rdbLoad(char *filename) { fp = fopen(filename,"r"); if (!fp) { - errno = ENOENT; return REDIS_ERR; } rioInitWithFile(&rdb,fp); diff --git a/src/redis.c b/src/redis.c index 1ddf2eef..8570bf2d 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2736,7 +2736,7 @@ void loadDataFromDisk(void) { redisLog(REDIS_NOTICE,"DB loaded from disk: %.3f seconds", (float)(ustime()-start)/1000000); } else if (errno != ENOENT) { - redisLog(REDIS_WARNING,"Fatal error loading the DB. Exiting."); + redisLog(REDIS_WARNING,"Fatal error loading the DB: %s. Exiting.",strerror(errno)); exit(1); } }