From fe8ce2b064feb40bdc46f9f858f4b165ddbb8237 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 24 Apr 2014 16:23:03 +0200 Subject: [PATCH] clusterLoadConfig() REDIS_ERR retval semantics refined. We should return REDIS_ERR to signal we can't read the configuration because there is no config file only after checking errno, othewise we risk to rewrite an existing file that was not accessible for some other reason. --- src/cluster.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index ecbcc0a92..be0522ca5 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -103,7 +103,16 @@ int clusterLoadConfig(char *filename) { char *line; int maxline, j; - if (fp == NULL) return REDIS_ERR; + if (fp == NULL) { + if (errno == ENOENT) { + return REDIS_ERR; + } else { + redisLog(REDIS_WARNING, + "Loading the cluster node config from %s: %s", + filename, strerror(errno)); + exit(1); + } + } /* Check if the file is zero-length: if so return REDIS_ERR to signal * we have to write the config. */