Skip to content

Commit 33b14ce

Browse files
authored
Make Odb Send and Sync (#763)
* libgit2-sys: build.rs: require 1.3.0 This ensures that we can count on new APIs and behavior, whether we're building our vendored version or using a system library. * Make `Odb` `Send` and `Sync` As of libgit2 1.2.0, `git_odb` uses locking internally, and should be thread-safe. Mark it `Send` and `Sync` to allow access from multiple threads.
1 parent 4949647 commit 33b14ce

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

libgit2-sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
1515
if try_to_use_system_libgit2 {
1616
let mut cfg = pkg_config::Config::new();
17-
if let Ok(lib) = cfg.atleast_version("1.1.0").probe("libgit2") {
17+
if let Ok(lib) = cfg.atleast_version("1.3.0").probe("libgit2") {
1818
for include in &lib.include_paths {
1919
println!("cargo:root={}", include.display());
2020
}

src/odb.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub struct Odb<'repo> {
1818
_marker: marker::PhantomData<Object<'repo>>,
1919
}
2020

21+
// `git_odb` uses locking and atomics internally.
22+
unsafe impl<'repo> Send for Odb<'repo> {}
23+
unsafe impl<'repo> Sync for Odb<'repo> {}
24+
2125
impl<'repo> Binding for Odb<'repo> {
2226
type Raw = *mut raw::git_odb;
2327

0 commit comments

Comments
 (0)