Commit fb659cd3 authored by antirez's avatar antirez
Browse files

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.
parent 6c63df30
...@@ -101,12 +101,19 @@ int clusterLoadConfig(char *filename) { ...@@ -101,12 +101,19 @@ int clusterLoadConfig(char *filename) {
line = zmalloc(maxline); line = zmalloc(maxline);
while(fgets(line,maxline,fp) != NULL) { while(fgets(line,maxline,fp) != NULL) {
int argc; int argc;
sds *argv = sdssplitargs(line,&argc); sds *argv;
if (argv == NULL) goto fmterr;
clusterNode *n, *master; clusterNode *n, *master;
char *p, *s; 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 */ /* Create this node if it does not exist */
n = clusterLookupNode(argv[0]); n = clusterLookupNode(argv[0]);
if (!n) { if (!n) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment