Skip to content

Commit e3cf812

Browse files
committed
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.
1 parent db06108 commit e3cf812

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/cluster.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ int clusterLoadConfig(char *filename) {
103103
char *line;
104104
int maxline, j;
105105

106-
if (fp == NULL) return REDIS_ERR;
106+
if (fp == NULL) {
107+
if (errno == ENOENT) {
108+
return REDIS_ERR;
109+
} else {
110+
redisLog(REDIS_WARNING,
111+
"Loading the cluster node config from %s: %s",
112+
filename, strerror(errno));
113+
exit(1);
114+
}
115+
}
107116

108117
/* Check if the file is zero-length: if so return REDIS_ERR to signal
109118
* we have to write the config. */

0 commit comments

Comments
 (0)