Skip to content

Commit

Permalink
Make Odb Send and Sync (#763)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
joshtriplett committed Nov 11, 2021
1 parent 4949647 commit 33b14ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libgit2-sys/build.rs
Expand Up @@ -14,7 +14,7 @@ fn main() {
let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
if try_to_use_system_libgit2 {
let mut cfg = pkg_config::Config::new();
if let Ok(lib) = cfg.atleast_version("1.1.0").probe("libgit2") {
if let Ok(lib) = cfg.atleast_version("1.3.0").probe("libgit2") {
for include in &lib.include_paths {
println!("cargo:root={}", include.display());
}
Expand Down
4 changes: 4 additions & 0 deletions src/odb.rs
Expand Up @@ -18,6 +18,10 @@ pub struct Odb<'repo> {
_marker: marker::PhantomData<Object<'repo>>,
}

// `git_odb` uses locking and atomics internally.
unsafe impl<'repo> Send for Odb<'repo> {}
unsafe impl<'repo> Sync for Odb<'repo> {}

impl<'repo> Binding for Odb<'repo> {
type Raw = *mut raw::git_odb;

Expand Down

0 comments on commit 33b14ce

Please sign in to comment.