diff options
author | Wez Furlong <wez@wezfurlong.org> | 2020-01-18 16:28:12 -0800 |
---|---|---|
committer | Wez Furlong <wez@wezfurlong.org> | 2020-01-18 16:28:12 -0800 |
commit | 92f466c07ccded1fe58f245320542cca69267e7e (patch) | |
tree | 1f0ae584aa79ab88a747a1acc402a2eafd19e983 /src | |
parent | a22780feb63945bd549735e17b48074b4d7b1419 (diff) | |
download | ssh2-rs-92f466c07ccded1fe58f245320542cca69267e7e.zip |
ChannelInner is Send + Sync
This allows Channel and Stream to be Send
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/channel.rs b/src/channel.rs index 1169a65..82ac981 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -14,6 +14,12 @@ struct ChannelInner { read_limit: Mutex<Option<u64>>, } +// ChannelInner is both Send and Sync; the compiler can't see it because it +// is pessimistic about the raw pointer. We use Arc/Mutex to guard accessing +// the raw pointer so we are safe for both. +unsafe impl Send for ChannelInner {} +unsafe impl Sync for ChannelInner {} + struct LockedChannel<'a> { raw: *mut raw::LIBSSH2_CHANNEL, sess: MutexGuard<'a, SessionInner>, |