Skip to content

Commit

Permalink
Merge pull request #585 from zeenix/disable-uds-on-windows+tokio
Browse files Browse the repository at this point in the history
🚩 zb: Disable UDS support on Windows for tokio
  • Loading branch information
zeenix authored Feb 11, 2024
2 parents be21e19 + 9f13788 commit 4d13c62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion zbus/src/blocking/connection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::os::unix::net::UnixStream;
use tokio::net::TcpStream;
#[cfg(all(unix, feature = "tokio"))]
use tokio::net::UnixStream;
#[cfg(windows)]
#[cfg(all(windows, not(feature = "tokio")))]
use uds_windows::UnixStream;

use zvariant::{ObjectPath, Str};
Expand Down Expand Up @@ -53,6 +53,12 @@ impl<'a> Builder<'a> {
/// If the default `async-io` feature is disabled, this method will expect
/// [`tokio::net::UnixStream`](https://docs.rs/tokio/latest/tokio/net/struct.UnixStream.html)
/// argument.
///
/// Since tokio currently [does not support Unix domain sockets][tuds] on Windows, this method
/// is not available when the `tokio` feature is enabled and building for Windows target.
///
/// [tuds]: https://github.com/tokio-rs/tokio/issues/2201
#[cfg(any(unix, not(feature = "tokio")))]
pub fn unix_stream(stream: UnixStream) -> Self {
Self(crate::connection::Builder::unix_stream(stream))
}
Expand Down
11 changes: 8 additions & 3 deletions zbus/src/connection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tokio::net::TcpStream;
use tokio::net::UnixStream;
#[cfg(feature = "tokio-vsock")]
use tokio_vsock::VsockStream;
#[cfg(windows)]
#[cfg(all(windows, not(feature = "tokio")))]
use uds_windows::UnixStream;
#[cfg(all(feature = "vsock", not(feature = "tokio")))]
use vsock::VsockStream;
Expand All @@ -42,6 +42,7 @@ const DEFAULT_MAX_QUEUED: usize = 64;

#[derive(Debug)]
enum Target {
#[cfg(any(unix, not(feature = "tokio")))]
UnixStream(UnixStream),
TcpStream(TcpStream),
#[cfg(any(
Expand Down Expand Up @@ -138,6 +139,12 @@ impl<'a> Builder<'a> {
/// If the default `async-io` feature is disabled, this method will expect
/// [`tokio::net::UnixStream`](https://docs.rs/tokio/latest/tokio/net/struct.UnixStream.html)
/// argument.
///
/// Since tokio currently [does not support Unix domain sockets][tuds] on Windows, this method
/// is not available when the `tokio` feature is enabled and building for Windows target.
///
/// [tuds]: https://github.com/tokio-rs/tokio/issues/2201
#[cfg(any(unix, not(feature = "tokio")))]
pub fn unix_stream(stream: UnixStream) -> Self {
Self::new(Target::UnixStream(stream))
}
Expand Down Expand Up @@ -485,8 +492,6 @@ impl<'a> Builder<'a> {
Target::UnixStream(stream) => Async::new(stream)?.into(),
#[cfg(all(unix, feature = "tokio"))]
Target::UnixStream(stream) => stream.into(),
#[cfg(all(not(unix), feature = "tokio"))]
Target::UnixStream(_) => return Err(Error::Unsupported),
#[cfg(not(feature = "tokio"))]
Target::TcpStream(stream) => Async::new(stream)?.into(),
#[cfg(feature = "tokio")]
Expand Down

0 comments on commit 4d13c62

Please sign in to comment.