Skip to content

Commit d6118c5

Browse files
committed
ra-rpc: drop redundant unix cfg gates
1 parent 8a3c4ac commit d6118c5

2 files changed

Lines changed: 1 addition & 16 deletions

File tree

guest-agent/src/server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::http_routes;
1010
use crate::rpc_service::{AppState, ExternalRpcHandler, InternalRpcHandler, InternalRpcHandlerV0};
1111
use crate::socket_activation::{ActivatedSockets, ActivatedUnixListener};
1212
use anyhow::{anyhow, Context, Result};
13-
#[cfg(unix)]
1413
use ra_rpc::rocket_helper::UnixPeerCredListener;
1514
use rocket::{
1615
fairing::AdHoc,

ra-rpc/src/rocket_helper.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ use std::{borrow::Cow, sync::Arc};
1818

1919
use anyhow::{Context, Result};
2020
use ra_tls::traits::CertExt;
21-
#[cfg(unix)]
2221
use rocket::listener::unix::UnixStream;
23-
#[cfg(unix)]
2422
use rocket::listener::{Connection, Listener};
25-
#[cfg(unix)]
2623
use rocket::tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
2724
use rocket::{
2825
data::{ByteUnit, Data, Limits, ToByteUnit},
@@ -59,39 +56,33 @@ impl<'r> Responder<'r, 'static> for RpcResponse {
5956
}
6057
}
6158

62-
#[cfg(unix)]
6359
#[derive(Debug, Clone)]
6460
struct UnixPeerEndpoint {
6561
path: PathBuf,
6662
peer: Option<UnixPeerCred>,
6763
}
6864

69-
#[cfg(unix)]
7065
impl fmt::Display for UnixPeerEndpoint {
7166
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7267
write!(f, "unix:{}", self.path.display())
7368
}
7469
}
7570

76-
#[cfg(unix)]
7771
pub struct UnixPeerCredListener<L> {
7872
inner: L,
7973
}
8074

81-
#[cfg(unix)]
8275
impl<L> UnixPeerCredListener<L> {
8376
pub fn new(inner: L) -> Self {
8477
Self { inner }
8578
}
8679
}
8780

88-
#[cfg(unix)]
8981
pub struct UnixPeerCredConnection {
9082
stream: UnixStream,
9183
endpoint: rocket::listener::Endpoint,
9284
}
9385

94-
#[cfg(unix)]
9586
impl AsyncRead for UnixPeerCredConnection {
9687
fn poll_read(
9788
mut self: Pin<&mut Self>,
@@ -102,7 +93,6 @@ impl AsyncRead for UnixPeerCredConnection {
10293
}
10394
}
10495

105-
#[cfg(unix)]
10696
impl AsyncWrite for UnixPeerCredConnection {
10797
fn poll_write(
10898
mut self: Pin<&mut Self>,
@@ -133,14 +123,12 @@ impl AsyncWrite for UnixPeerCredConnection {
133123
}
134124
}
135125

136-
#[cfg(unix)]
137126
impl Connection for UnixPeerCredConnection {
138127
fn endpoint(&self) -> io::Result<rocket::listener::Endpoint> {
139128
Ok(self.endpoint.clone())
140129
}
141130
}
142131

143-
#[cfg(unix)]
144132
impl<L> Listener for UnixPeerCredListener<L>
145133
where
146134
L: Listener<Accept = UnixStream, Connection = UnixStream>,
@@ -183,7 +171,6 @@ where
183171
}
184172
}
185173

186-
#[cfg(unix)]
187174
fn unix_peer_cred(stream: &UnixStream) -> Option<UnixPeerCred> {
188175
let cred = stream.peer_cred().ok()?;
189176
let pid = cred.pid()?;
@@ -412,7 +399,6 @@ impl From<Endpoint> for RemoteEndpoint {
412399
Endpoint::Tcp(addr) => RemoteEndpoint::Tcp(addr),
413400
Endpoint::Quic(addr) => RemoteEndpoint::Quic(addr),
414401
Endpoint::Unix(path) => RemoteEndpoint::Unix { path, peer: None },
415-
#[cfg(unix)]
416402
Endpoint::Custom(endpoint) => {
417403
if let Some(endpoint) =
418404
(endpoint.as_ref() as &dyn std::any::Any).downcast_ref::<UnixPeerEndpoint>()
@@ -447,7 +433,7 @@ impl From<Endpoint> for RemoteEndpoint {
447433
}
448434
}
449435

450-
#[cfg(all(test, unix))]
436+
#[cfg(test)]
451437
mod tests {
452438
use super::*;
453439
use rocket::listener::unix::UnixListener;

0 commit comments

Comments
 (0)