diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-11-20 14:24:50 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-03 11:25:12 +0100 |
commit | b4ab151739bb7295414375312f7fca3fe7b31e71 (patch) | |
tree | e0acd1ad14f075aa3e3e45013ec15921c9f4129e /src/buildtool/serve_api/serve_service/source_tree.cpp | |
parent | 0a8d81cccc994a0b01324d58c01420f26c02116d (diff) | |
download | justbuild-b4ab151739bb7295414375312f7fca3fe7b31e71.tar.gz |
Serve service: properly lock git operations against each other
... by using an exclusive lock. A lock of which only ever shared instances
are requested has no synchronisation effect. Fix this.
(cherry-picked from dfb7ad5c7d5dcca13d9728534434079a2b60bdea)
Diffstat (limited to 'src/buildtool/serve_api/serve_service/source_tree.cpp')
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp index 560d96d3..9fb2dae4 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.cpp +++ b/src/buildtool/serve_api/serve_service/source_tree.cpp @@ -17,7 +17,6 @@ #include "src/buildtool/serve_api/serve_service/source_tree.hpp" #include <algorithm> -#include <shared_mutex> #include <thread> #include "fmt/core.h" @@ -539,7 +538,7 @@ auto SourceTreeService::ResolveContentTree( }); { // this is a non-thread-safe Git operation, so it must be guarded! - std::shared_lock slock{mutex_}; + std::unique_lock slock{mutex_}; // open real repository at Git CAS location auto git_repo = GitRepo::Open(native_context_->storage_config->GitRoot()); @@ -661,7 +660,7 @@ auto SourceTreeService::CommonImportToGit( // tag commit and keep it in Git CAS { // this is a non-thread-safe Git operation, so it must be guarded! - std::shared_lock slock{mutex_}; + std::unique_lock slock{mutex_}; // open real repository at Git CAS location auto git_repo = GitRepo::Open(native_context_->storage_config->GitRoot()); |