Skip to content

Commit db38859

Browse files
committed
Add clippy allow arc_with_non_send_sync for Capture
1 parent f896836 commit db38859

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/capture/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl PcapHandle {
106106
}
107107

108108
// `PcapHandle` is safe to Send as it encapsulates the entire lifetime of `raw::pcap_t *`, but it is
109-
// not safe to Sync as libpcap does not promise thread-safe access to the same `raw::pcap_t *` from
110-
// multiple threads.
109+
// `PcapHandle` is only Sync under special circumstances when used in thread-safe functions such as
110+
// the `pcap_breakloop` function. The Sync correctness is left to the wrapping structure to provide.
111111
unsafe impl Send for PcapHandle {}
112112

113113
impl Drop for PcapHandle {
@@ -118,6 +118,9 @@ impl Drop for PcapHandle {
118118

119119
unsafe impl<T: State + ?Sized> Send for Capture<T> {}
120120

121+
// `Capture` is not safe to implement Sync as the libpcap functions it uses are not promised to have
122+
// thread-safe access to the same `raw::pcap_t *` from multiple threads.
123+
#[allow(clippy::arc_with_non_send_sync)]
121124
impl<T: State + ?Sized> From<NonNull<raw::pcap_t>> for Capture<T> {
122125
fn from(handle: NonNull<raw::pcap_t>) -> Self {
123126
Capture {

0 commit comments

Comments
 (0)