summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2020-08-02 16:26:25 -0700
committerlhchavez <lhchavez@lhchavez.com>2020-11-28 15:12:14 -0800
commit4ae41f9c639d246d34dac89c3f1d9451c9cfa8d3 (patch)
tree5e207fe654fb3c5a7a6a4bbcc490f982e2ececc7 /src/repository.c
parentef6de8d5d1c0e70f974d9c11e74f87f852b7c3ee (diff)
downloadlibgit2-4ae41f9c639d246d34dac89c3f1d9451c9cfa8d3.tar.gz
Make the odb race-free
This change adds all the necessary locking to the odb to avoid races in the backends. Part of: #5592
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index 697d6dfe9..bef84caaf 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1107,7 +1107,8 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
GIT_ASSERT_ARG(repo);
GIT_ASSERT_ARG(out);
- if (repo->_odb == NULL) {
+ *out = git__load(repo->_odb);
+ if (*out == NULL) {
git_buf odb_path = GIT_BUF_INIT;
git_odb *odb;
@@ -1131,9 +1132,9 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
}
git_buf_dispose(&odb_path);
+ *out = git__load(repo->_odb);
}
- *out = repo->_odb;
return error;
}