Cluster: ignore empty lines in nodes.conf.

Even without the user messing manually with the file, it is still
possible to have blank lines (just a single "\n" per line) because of
how the nodes.conf update/write process works.
This commit is contained in:
antirez 2014-01-15 11:23:34 +01:00
parent 6c63df3031
commit fb659cd334

View File

@ -101,12 +101,19 @@ int clusterLoadConfig(char *filename) {
line = zmalloc(maxline);
while(fgets(line,maxline,fp) != NULL) {
int argc;
sds *argv = sdssplitargs(line,&argc);
if (argv == NULL) goto fmterr;
sds *argv;
clusterNode *n, *master;
char *p, *s;
/* Skip blank lines, they can be created either by users manually
* editing nodes.conf or by the config writing process if stopped
* before the truncate() call. */
if (line[0] == '\n') continue;
/* Split the line into arguments for processing. */
argv = sdssplitargs(line,&argc);
if (argv == NULL) goto fmterr;
/* Create this node if it does not exist */
n = clusterLookupNode(argv[0]);
if (!n) {