|
|
|
@ -12,7 +12,7 @@ use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
|
|
|
|
|
use crate::path::Path;
|
|
|
|
|
use crate::rt::Watcher;
|
|
|
|
|
use crate::stream::Stream;
|
|
|
|
|
use crate::task::{spawn_blocking, Context, Poll};
|
|
|
|
|
use crate::task::{Context, Poll};
|
|
|
|
|
|
|
|
|
|
/// A Unix domain socket server, listening for connections.
|
|
|
|
|
///
|
|
|
|
@ -67,10 +67,10 @@ impl UnixListener {
|
|
|
|
|
/// ```
|
|
|
|
|
pub async fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixListener> {
|
|
|
|
|
let path = path.as_ref().to_owned();
|
|
|
|
|
let listener = spawn_blocking(move || mio::net::UnixListener::bind(path)).await?;
|
|
|
|
|
let mio_listener = mio::net::UnixListener::bind(path)?;
|
|
|
|
|
|
|
|
|
|
Ok(UnixListener {
|
|
|
|
|
watcher: Watcher::new(listener),
|
|
|
|
|
watcher: Watcher::new(mio_listener),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -92,10 +92,9 @@ impl UnixListener {
|
|
|
|
|
/// ```
|
|
|
|
|
pub async fn accept(&self) -> io::Result<(UnixStream, mio::net::SocketAddr)> {
|
|
|
|
|
future::poll_fn(|cx| {
|
|
|
|
|
let res =
|
|
|
|
|
futures_core::ready!(self.watcher.poll_read_with(cx, |inner| { inner.accept() }));
|
|
|
|
|
let (mio_stream, addr) =
|
|
|
|
|
futures_core::ready!(self.watcher.poll_read_with(cx, |inner| { inner.accept() }))?;
|
|
|
|
|
|
|
|
|
|
let (mio_stream, addr) = res?;
|
|
|
|
|
let stream = UnixStream {
|
|
|
|
|
watcher: Watcher::new(mio_stream),
|
|
|
|
|
};
|
|
|
|
|