Skip to content

Commit

Permalink
Implement Sync for Link
Browse files Browse the repository at this point in the history
Implement Sync for Link. The only operations that can be performed on a
&Link are pin_path() and detach(), neither of which modify the object.
pin_path() just reads an attribute and detach() performs a system call
with the link's file descriptor. Hence, Sync should be fine to implement
for Link.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o committed Dec 19, 2024
1 parent 69b910f commit b9f610a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions libbpf-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-------------
- Adjusted `btf::types::EnumMember` to store value as `i64`
- Adjusted `btf::types::Enum64Member` to store value as `i128`
- Implemented `Sync` for `Link`


0.25.0-beta.0
Expand Down
2 changes: 2 additions & 0 deletions libbpf-rs/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ impl AsRawLibbpf for Link {

// SAFETY: `bpf_link` objects can safely be sent to a different thread.
unsafe impl Send for Link {}
// SAFETY: `bpf_link` has no interior mutability.
unsafe impl Sync for Link {}

impl AsFd for Link {
#[inline]
Expand Down

0 comments on commit b9f610a

Please sign in to comment.