Skip to content

Commit

Permalink
Add CHANGELOG entry for #1028
Browse files Browse the repository at this point in the history
Add a CHANGELOG entry for pull request #1028, which added Send + Sync
bounds to the OpenObject and Object types. Also add missing SAFETY
comments.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o authored and danielocfb committed Dec 5, 2024
1 parent 2d9bff1 commit a86616c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions libbpf-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.25.0-beta.0
-------------
- Added `Map::lookup_batch` and `Map::lookup_and_delete_batch` method
- Added `Send` & `Sync` impl for `OpenObject` & `Object` types


0.24.8
Expand Down
17 changes: 11 additions & 6 deletions libbpf-rs/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,6 @@ pub struct OpenObject {
ptr: NonNull<libbpf_sys::bpf_object>,
}

unsafe impl Send for OpenObject {}
unsafe impl Sync for OpenObject {}

impl OpenObject {
/// Takes ownership from pointer.
///
Expand Down Expand Up @@ -299,6 +296,11 @@ impl OpenObject {
}
}

// SAFETY: `bpf_object` is freely transferable between threads.
unsafe impl Send for OpenObject {}
// SAFETY: `bpf_object` has no interior mutability.
unsafe impl Sync for OpenObject {}

impl AsRawLibbpf for OpenObject {
type LibbpfType = libbpf_sys::bpf_object;

Expand All @@ -317,6 +319,7 @@ impl Drop for OpenObject {
}
}


/// Represents a loaded BPF object file.
///
/// An `Object` is logically in charge of all the contained [`Program`]s and [`Map`]s as well as
Expand All @@ -332,9 +335,6 @@ pub struct Object {
ptr: NonNull<libbpf_sys::bpf_object>,
}

unsafe impl Send for Object {}
unsafe impl Sync for Object {}

impl Object {
/// Takes ownership from pointer.
///
Expand Down Expand Up @@ -393,6 +393,11 @@ impl Object {
}
}

// SAFETY: `bpf_object` is freely transferable between threads.
unsafe impl Send for Object {}
// SAFETY: `bpf_object` has no interior mutability.
unsafe impl Sync for Object {}

impl AsRawLibbpf for Object {
type LibbpfType = libbpf_sys::bpf_object;

Expand Down

0 comments on commit a86616c

Please sign in to comment.