Skip to content

Commit

Permalink
use std::io::ErrorKind instead of errno
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Dec 9, 2022
1 parent 1741bfb commit c15f8ab
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions realm_core/src/tcp/plain.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
use std::io::Result;
use tokio::net::TcpStream;

const EINVAL: i32 = 22;

#[inline]
pub async fn run_relay(mut local: TcpStream, mut remote: TcpStream) -> Result<()> {
#[cfg(all(target_os = "linux"))]
{
use std::io::ErrorKind;
match realm_io::bidi_zero_copy(&mut local, &mut remote).await {
Ok(()) => Ok(()),
Err(ref e) if e.raw_os_error().map_or(false, |ec| ec == EINVAL) => {
realm_io::bidi_copy(&mut local, &mut remote).await
}
Err(ref e) if e.kind() == ErrorKind::InvalidInput => realm_io::bidi_copy(&mut local, &mut remote).await,
Err(e) => Err(e),
}
}
Expand Down

0 comments on commit c15f8ab

Please sign in to comment.