Skip to content

Commit

Permalink
Check for EINPROGRESS in UnixStream::connect
Browse files Browse the repository at this point in the history
  • Loading branch information
Stjepan Glavina committed May 7, 2020
1 parent 34fcc57 commit ef701a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ use std::{
use futures::future;
use futures::io::{AsyncRead, AsyncWrite};
use futures::stream::{self, Stream};
#[cfg(unix)]
use nix::libc;
use socket2::{Domain, Protocol, Socket, Type};

use crate::reactor::{Reactor, Source};
use crate::task::Task;

#[cfg(unix)]
use nix::libc;

/// Async I/O.
///
/// This type converts a blocking I/O type into an async type, provided it is supported by
Expand Down Expand Up @@ -874,12 +873,12 @@ impl Async<UnixStream> {
// Create a socket.
let socket = Socket::new(Domain::unix(), Type::stream(), None)?;

// Begin async connect and ignore the inevitable "not yet connected" error.
// Begin async connect and ignore the inevitable "in progress" error.
socket.set_nonblocking(true)?;
socket
.connect(&socket2::SockAddr::unix(path)?)
.or_else(|err| {
if err.kind() == io::ErrorKind::NotConnected {
if err.raw_os_error() == Some(libc::EINPROGRESS) {
Ok(())
} else {
Err(err)
Expand Down

0 comments on commit ef701a4

Please sign in to comment.