Close config files on error.

pull/211/merge
Roger A. Light 12 years ago
parent a229b05f58
commit c13f4c7931

@ -518,10 +518,9 @@ int mqtt3_config_read(struct mqtt3_config *config, bool reload)
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
} }
int _config_read_file(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno) int _config_read_file_core(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno, FILE *fptr)
{ {
int rc; int rc;
FILE *fptr = NULL;
char buf[1024]; char buf[1024];
char *token; char *token;
int port_tmp; int port_tmp;
@ -548,12 +547,6 @@ int _config_read_file(struct mqtt3_config *config, bool reload, const char *file
int i; int i;
#endif #endif
int lineno_ext; int lineno_ext;
fptr = _mosquitto_fopen(file, "rt");
if(!fptr){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open config file %s\n", file);
return 1;
}
*lineno = 0; *lineno = 0;
@ -1781,9 +1774,24 @@ int _config_read_file(struct mqtt3_config *config, bool reload, const char *file
} }
} }
} }
return MOSQ_ERR_SUCCESS;
}
int _config_read_file(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno)
{
int rc;
FILE *fptr = NULL;
fptr = _mosquitto_fopen(file, "rt");
if(!fptr){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open config file %s\n", file);
return 1;
}
rc = _config_read_file_core(config, reload, file, cr, level, lineno, fptr);
fclose(fptr); fclose(fptr);
return MOSQ_ERR_SUCCESS; return rc;
} }
static int _conf_parse_bool(char **token, const char *name, bool *value, char *saveptr) static int _conf_parse_bool(char **token, const char *name, bool *value, char *saveptr)

Loading…
Cancel
Save