config: use getc_unlocked when reading from file
[gitweb.git] / config.c
index 66c0a51bce529e4c027f11017697a62dd737b3bd..8b297fc4e5e05c2ad817f41399827d603e94d844 100644 (file)
--- a/config.c
+++ b/config.c
@@ -49,7 +49,7 @@ static struct config_set the_config_set;
 
 static int config_file_fgetc(struct config_source *conf)
 {
-       return fgetc(conf->u.file);
+       return getc_unlocked(conf->u.file);
 }
 
 static int config_file_ungetc(int c, struct config_source *conf)
@@ -1088,7 +1088,9 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
 
        f = fopen(filename, "r");
        if (f) {
+               flockfile(f);
                ret = do_config_from_file(fn, filename, filename, f, data);
+               funlockfile(f);
                fclose(f);
        }
        return ret;