Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ fn connect(
target_os = "watchos",
))]
{
#[allow(unsafe_code)]
let idx = unsafe { libc::if_nametoindex(interface.as_ptr()) };
let idx = std::num::NonZeroU32::new(idx).ok_or_else(|| {
// If the index is 0, check errno and return an I/O error.
Expand Down
18 changes: 5 additions & 13 deletions src/core/rt/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ where
cx: &mut Context<'_>,
buf: ReadBufCursor<'_>,
) -> Poll<std::io::Result<()>> {
pin_as_deref_mut(self).poll_read(cx, buf)
self.as_deref_mut().poll_read(cx, buf)
}
}

Expand Down Expand Up @@ -350,38 +350,30 @@ where
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<std::io::Result<usize>> {
pin_as_deref_mut(self).poll_write(cx, buf)
self.as_deref_mut().poll_write(cx, buf)
}

fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[std::io::IoSlice<'_>],
) -> Poll<std::io::Result<usize>> {
pin_as_deref_mut(self).poll_write_vectored(cx, bufs)
self.as_deref_mut().poll_write_vectored(cx, bufs)
}

fn is_write_vectored(&self) -> bool {
(**self).is_write_vectored()
}

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
pin_as_deref_mut(self).poll_flush(cx)
self.as_deref_mut().poll_flush(cx)
}

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
pin_as_deref_mut(self).poll_shutdown(cx)
self.as_deref_mut().poll_shutdown(cx)
}
}

/// Polyfill for Pin::as_deref_mut()
/// TODO: use Pin::as_deref_mut() instead once stabilized
fn pin_as_deref_mut<P: DerefMut>(pin: Pin<&mut Pin<P>>) -> Pin<&mut P::Target> {
// SAFETY: we go directly from Pin<&mut Pin<P>> to Pin<&mut P::Target>, without moving or
// giving out the &mut Pin<P> in the process. See Pin::as_deref_mut() for more detail.
unsafe { pin.get_unchecked_mut() }.as_mut()
}

pub(crate) async fn read<T>(io: &mut T, buf: &mut [u8]) -> Result<usize, std::io::Error>
where
T: Read + Unpin,
Expand Down
1 change: 1 addition & 0 deletions src/tls/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl Inner {
// If the session cache is enabled, we try to retrieve the session
// associated with the key. If it exists, we set it in the SSL configuration.
if let Some(session) = cache.lock().get(&key) {
#[allow(unsafe_code)]
unsafe { cfg.set_session(&session) }?;

if self.config.no_ticket {
Expand Down
Loading