Skip to content

Commit b071a39

Browse files
committed
refactor: minor fixes
1 parent 5e8581e commit b071a39

4 files changed

Lines changed: 5 additions & 55 deletions

File tree

crates/ironrdp-dvc-pipe-proxy/src/message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use ironrdp_core::{ensure_size, Encode, EncodeResult};
22
use ironrdp_dvc::DvcEncode;
33

4+
// Pseudo-message for sanding any encoded data through the DVC channel.
45
pub(crate) struct RawDataDvcMessage(pub Vec<u8>);
56

67
impl Encode for RawDataDvcMessage {

crates/ironrdp-dvc-pipe-proxy/src/platform/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Platform-specific code for DVC pipe proxy.
2+
13
#[cfg(target_os = "windows")]
24
pub(crate) mod windows;
35

crates/ironrdp-dvc-pipe-proxy/src/platform/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl OsPipe for UnixPipe {
2828
if !metadata.file_type().is_socket() {
2929
return Err(DvcPipeProxyError::Io(std::io::Error::new(
3030
std::io::ErrorKind::InvalidInput,
31-
format!("Path {} is not a socket", pipe_name),
31+
format!("Path {pipe_name} is not a socket"),
3232
)));
3333
}
3434

crates/ironrdp-dvc-pipe-proxy/src/worker.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::error::DvcPipeProxyError;
99
use crate::message::RawDataDvcMessage;
1010
use crate::os_pipe::OsPipe;
1111

12-
const IO_BUFFER_SIZE: usize = 1024 * 64; // 64K
12+
const IO_BUFFER_SIZE: usize = 1024 * 64;
1313

1414
pub(crate) type OnWriteDvcMessage = Box<dyn Fn(u32, Vec<SvcMessage>) -> PduResult<()> + Send>;
1515

@@ -65,59 +65,6 @@ async fn process_client<P: OsPipe>(ctx: &mut WorkerCtx) -> Result<NextWorkerStat
6565
let pipe_name = &ctx.pipe_name;
6666
let channel_name = &ctx.channel_name;
6767

68-
/*
69-
match fs::metadata(&ctx.pipe_name).await
70-
{
71-
Ok(metadata) => {
72-
use std::os::unix::fs::FileTypeExt;
73-
74-
info!(
75-
%channel_name,
76-
%pipe_name,
77-
"DVC pipe already exists, removing stale file."
78-
);
79-
80-
// Just to be sure, check if it's indeed a socket -
81-
// throw an error if calling code accidentally passed a regular file.
82-
if !metadata.file_type().is_socket() {
83-
return Err(DvcPipeProxyError::Io(std::io::Error::new(
84-
std::io::ErrorKind::InvalidInput,
85-
format!("Path {} is not a socket", ctx.pipe_name),
86-
)));
87-
}
88-
89-
fs::remove_file(&ctx.pipe_name).await.map_err(DvcPipeProxyError::Io)?;
90-
}
91-
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
92-
trace!(
93-
%pipe_name,
94-
%channel_name,
95-
"DVC pipe does not exist, creating it."
96-
);
97-
}
98-
Err(e) => {
99-
return Err(DvcPipeProxyError::Io(e));
100-
}
101-
}
102-
103-
let listener = tokio::net::UnixListener::bind(&ctx.pipe_name)
104-
.map_err(DvcPipeProxyError::Io)?;
105-
106-
info!(%pipe_name, %pipe_name, "Waiting for DVC pipe connection...");
107-
108-
let mut pipe = tokio::select! {
109-
stream = listener.accept() => {
110-
let (pipe, _) = stream.map_err(DvcPipeProxyError::Io)?;
111-
info!(%channel_name, %pipe_name,"DVC proxy worker thread has started.");
112-
pipe
113-
}
114-
_ = ctx.abort_event.notified() => {
115-
info!(%channel_name, %pipe_name, "DVC proxy worker thread has been aborted.");
116-
return Ok(NextWorkerState::Abort);
117-
}
118-
};
119-
*/
120-
12168
let mut pipe = tokio::select! {
12269
pipe = P::connect(pipe_name) => {
12370
info!(%channel_name, %pipe_name,"DVC proxy worker thread has started.");

0 commit comments

Comments
 (0)