From fb659cd334fde195cc86a4cb8cbecacc9b7358f5 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 15 Jan 2014 11:23:34 +0100 Subject: [PATCH] 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. --- src/cluster.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 8b698080a..dfba18411 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -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) {