[sheepdog] Why creating config if the file is not found or empty?

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Jun 10 09:15:17 CEST 2014


At Tue, 10 Jun 2014 16:06:08 +0900,
Hitoshi Mitake wrote:
> 
> 
> Hi Ruoyu,
> 
> At Tue, 10 Jun 2014 10:14:56 +0800,
> Ruoyu wrote:
> > 
> > Hi Hitoshi,
> > 
> > As titled, once one of the two conditions is matched, sheep process 
> > create a new config file.
> > However, cluster info is not assigned at this time so that sheep will 
> > crash at one of the following step.
> > Why not directly reporting error message and return -1?
> 
> I think the two condition can be true when user removes or breaks
> config file mistakenly even after cluster format. But I agree with
> your proposal because current behavior is really confusing.

On the second thought, current behavior is not so bad. Because it is
hard to detect the config file is not created yet or lost. But anyway
config file with 0 length should be treated as an error.

Thanks,
Hitoshi

> 
> Thanks,
> Hitoshi
> 
> > 
> > 
> > int init_config_file(void)
> > {
> >      int fd, ret;
> > 
> >      check_tmp_config();
> > 
> >      fd = open(config_path, O_RDONLY);
> >      if (fd < 0) {
> >          if (errno != ENOENT) {
> >              sd_err("failed to read config file, %m");
> >              return -1;
> >          }
> >          goto create;
> >      }
> > 
> >      ret = xread(fd, &config, sizeof(config));
> >      if (ret == 0) {
> >          close(fd);
> >          goto create;
> >      }
> >      if (ret < 0) {
> >          sd_err("failed to read config file, %m");
> >          goto out;
> >      }
> > ...
> > }
> > 
> > -- 
> > sheepdog mailing list
> > sheepdog at lists.wpkg.org
> > http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list