Skip to content

Commit

Permalink
Switch to unbounded channels for Reply (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
chipsenkbeil authored Jun 19, 2023
1 parent da75801 commit 7c08495
Show file tree
Hide file tree
Showing 22 changed files with 181 additions and 254 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `GenericServerRef` to `ServerRef` and remove `ServerRef` trait,
refactoring `TcpServerRef`, `UnixSocketServerRef`, and `WindowsPipeServerRef`
to use the struct instead of `Box<dyn ServerRef>`
- Update `Reply` trait and associated implementations to be non-blocking &
synchronous as opposed to asynchronous to avoid deadlocks and also be more
performant

## [0.20.0-alpha.8]

Expand Down
4 changes: 2 additions & 2 deletions distant-core/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ where
// Queue up our result to go before ANY of the other messages that might be sent.
// This is important to avoid situations such as when a process is started, but before
// the confirmation can be sent some stdout or stderr is captured and sent first.
if let Err(x) = reply.send_before(response).await {
if let Err(x) = reply.send_before(response) {
error!("[Conn {}] Failed to send response: {}", connection_id, x);
}

// Flush out all of our replies thus far and toggle to no longer hold submissions
if let Err(x) = reply.flush(false).await {
if let Err(x) = reply.flush(false) {
error!(
"[Conn {}] Failed to flush response queue: {}",
connection_id, x
Expand Down
8 changes: 1 addition & 7 deletions distant-core/src/api/reply.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::future::Future;
use std::io;
use std::pin::Pin;

use distant_net::server::Reply;

Expand All @@ -19,14 +17,10 @@ impl From<Box<dyn Reply<Data = protocol::Msg<protocol::Response>>>> for DistantS
impl Reply for DistantSingleReply {
type Data = protocol::Response;

fn send(&self, data: Self::Data) -> Pin<Box<dyn Future<Output = io::Result<()>> + Send + '_>> {
fn send(&self, data: Self::Data) -> io::Result<()> {
self.0.send(protocol::Msg::Single(data))
}

fn blocking_send(&self, data: Self::Data) -> io::Result<()> {
self.0.blocking_send(protocol::Msg::Single(data))
}

fn clone_reply(&self) -> Box<dyn Reply<Data = Self::Data>> {
Box::new(Self(self.0.clone_reply()))
}
Expand Down
Loading

0 comments on commit 7c08495

Please sign in to comment.