Skip to content

Commit 5d8da91

Browse files
committed
Merge branch 'jk/flockfile-stdio'
Code clean-up. * jk/flockfile-stdio: config: move flockfile() closer to unlocked functions
2 parents 850e925 + 05e293c commit 5d8da91

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

config.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ static int do_config_from_file(config_fn_t fn,
14261426
void *data)
14271427
{
14281428
struct config_source top;
1429+
int ret;
14291430

14301431
top.u.file = f;
14311432
top.origin_type = origin_type;
@@ -1436,7 +1437,10 @@ static int do_config_from_file(config_fn_t fn,
14361437
top.do_ungetc = config_file_ungetc;
14371438
top.do_ftell = config_file_ftell;
14381439

1439-
return do_config_from(&top, fn, data);
1440+
flockfile(f);
1441+
ret = do_config_from(&top, fn, data);
1442+
funlockfile(f);
1443+
return ret;
14401444
}
14411445

14421446
static int git_config_from_stdin(config_fn_t fn, void *data)
@@ -1451,9 +1455,7 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
14511455

14521456
f = fopen_or_warn(filename, "r");
14531457
if (f) {
1454-
flockfile(f);
14551458
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename, filename, f, data);
1456-
funlockfile(f);
14571459
fclose(f);
14581460
}
14591461
return ret;

0 commit comments

Comments
 (0)