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

Ruoyu liangry at ucweb.com
Tue Jun 10 04:14:56 CEST 2014

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?

int init_config_file(void)
     int fd, ret;


     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) {
         goto create;
     if (ret < 0) {
         sd_err("failed to read config file, %m");
         goto out;

More information about the sheepdog mailing list