summaryrefslogtreecommitdiff
path: root/src/config_file.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-11 14:45:37 -0800
committerRussell Belfer <rb@github.com>2014-04-17 14:43:45 -0700
commit40ed499039f887ebcb0b5badf0157519148398b8 (patch)
treeabf8307b9960aed3eb6911fadc26bb0627b7ecf2 /src/config_file.c
parent3b4c401a38ce912d5be8c9bf4ab1c4912a4f08bd (diff)
downloadlibgit2-40ed499039f887ebcb0b5badf0157519148398b8.tar.gz
Add diff threading tests and attr file cache locks
This adds a basic test of doing simultaneous diffs on multiple threads and adds basic locking for the attr file cache because that was the immediate problem that arose from these tests.
Diffstat (limited to 'src/config_file.c')
-rw-r--r--src/config_file.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/config_file.c b/src/config_file.c
index aedf2cb12..bb26aa8a3 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -180,11 +180,15 @@ static int config_open(git_config_backend *cfg, git_config_level_t level)
b->level = level;
- b->values = git_strmap_alloc();
- GITERR_CHECK_ALLOC(b->values);
+ if ((res = git_strmap_alloc(&b->values)) < 0)
+ return res;
git_array_init(b->readers);
reader = git_array_alloc(b->readers);
+ if (!reader) {
+ git_strmap_free(b->values);
+ return -1;
+ }
memset(reader, 0, sizeof(struct reader));
reader->file_path = git__strdup(b->file_path);
@@ -205,6 +209,7 @@ static int config_open(git_config_backend *cfg, git_config_level_t level)
reader = git_array_get(b->readers, 0);
git_buf_free(&reader->buffer);
+
return res;
}
@@ -218,8 +223,10 @@ static int config_refresh(git_config_backend *cfg)
for (i = 0; i < git_array_size(b->readers); i++) {
reader = git_array_get(b->readers, i);
+
res = git_futils_readbuffer_updated(
- &reader->buffer, reader->file_path, &reader->file_mtime, &reader->file_size, &updated);
+ &reader->buffer, reader->file_path,
+ &reader->file_mtime, &reader->file_size, &updated);
if (res < 0)
return (res == GIT_ENOTFOUND) ? 0 : res;
@@ -233,10 +240,9 @@ static int config_refresh(git_config_backend *cfg)
/* need to reload - store old values and prep for reload */
old_values = b->values;
- b->values = git_strmap_alloc();
- GITERR_CHECK_ALLOC(b->values);
-
- if ((res = config_parse(b, reader, b->level, 0)) < 0) {
+ if ((res = git_strmap_alloc(&b->values)) < 0) {
+ b->values = old_values;
+ } else if ((res = config_parse(b, reader, b->level, 0)) < 0) {
free_vars(b->values);
b->values = old_values;
} else {