From 9325d9b97efe448701a518a95725e8ba3ac7245c Mon Sep 17 00:00:00 2001 From: Shell Chen Date: Thu, 24 Dec 2020 13:22:32 +0800 Subject: [PATCH] Fix building fail on Windows --- src/main.rs | 9 ++++----- src/stream.rs | 6 +++++- src/web/mod.rs | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 518fa63..c83de66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ use clap::{load_yaml, AppSettings}; use futures_util::{stream, StreamExt}; use ini::Ini; use log::{debug, error, info, warn, LevelFilter}; -use parking_lot::deadlock; use std::{ collections::HashSet, env, @@ -23,16 +22,16 @@ use tokio::{ #[cfg(all(feature = "systemd", target_os = "linux"))] use moproxy::systemd; -#[cfg(target_os = "linux")] -use moproxy::tcp::set_congestion; #[cfg(feature = "web_console")] use moproxy::web; use moproxy::{ client::{Connectable, NewClient}, monitor::{Monitor, ServerList}, proxy::{ProxyProto, ProxyServer, UserPassAuthCredential}, - stream::{TcpListenerStream, UnixListenerStream}, + stream::TcpListenerStream, }; +#[cfg(target_os = "linux")] +use moproxy::{stream::UnixListenerStream, tcp::set_congestion}; trait FromOptionStr> { fn parse(&self) -> Result, E>; @@ -177,7 +176,7 @@ async fn main() { systemd::notify_realoding(); // feature: check deadlocks on signal - let deadlocks = deadlock::check_deadlock(); + let deadlocks = parking_lot::deadlock::check_deadlock(); if !deadlocks.is_empty() { error!("{} deadlocks detected!", deadlocks.len()); for (i, threads) in deadlocks.iter().enumerate() { diff --git a/src/stream.rs b/src/stream.rs index a0d6184..43f6939 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -3,7 +3,9 @@ use std::{ io::Result, task::{Context, Poll}, }; -use tokio::net::{TcpListener, TcpStream, UnixListener, UnixStream}; +use tokio::net::{TcpListener, TcpStream}; +#[cfg(unix)] +use tokio::net::{UnixListener, UnixStream}; macro_rules! impl_stream { ($name:ident : $listener:ty => $stream:ty) => { @@ -24,4 +26,6 @@ macro_rules! impl_stream { } impl_stream!(TcpListenerStream: TcpListener => TcpStream); + +#[cfg(unix)] impl_stream!(UnixListenerStream: UnixListener => UnixStream); diff --git a/src/web/mod.rs b/src/web/mod.rs index 3d7e2bd..19a581e 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -22,7 +22,6 @@ use std::{ sync::Arc, time::{Duration, Instant}, }; -#[cfg(unix)] use tokio::{ self, io::{AsyncRead, AsyncWrite},