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.
This commit is contained in:
parent
52668c900f
commit
fe8ce2b064
@ -103,7 +103,16 @@ int clusterLoadConfig(char *filename) {
|
|||||||
char *line;
|
char *line;
|
||||||
int maxline, j;
|
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
|
/* Check if the file is zero-length: if so return REDIS_ERR to signal
|
||||||
* we have to write the config. */
|
* we have to write the config. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user