Skip to content

Commit

Permalink
Fix PadResponse mpsc saturation after 100 request
Browse files Browse the repository at this point in the history
The PadResponse::Ok sent over `from_pad` channel
was never read by the server, which always happens
in case of MotorWrite requests.
- Stopped sending PadResponse::Ok after responding
to MotorWrite

This caused the entire process to freeze up after
100 requests had been sent.
  • Loading branch information
kknives committed Dec 29, 2022
1 parent 4e524ee commit ea69fb0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use eyre::{WrapErr, Result};
use postcard::{from_bytes, to_slice};
use serde::{Deserialize, Serialize};
use tokio::net::UnixListener;
use tracing::{error, info};
use tracing::{error, info, debug};

use git_version::git_version;
const GIT_VERSION: &str = git_version!();
Expand Down Expand Up @@ -44,11 +44,14 @@ async fn main() -> Result<()> {
loop {
tokio::select! {
_ = interval.tick() => {
pad.keep_alive();
pad.keep_alive().await.map_err(|e| error!("Error sending KeepAlive: {}", e)).ok();
}
pad_req = recv_from_server.recv() => {
let response = pad.respond(pad_req.unwrap());
send_to_server.send(response).await.unwrap();
debug!("Got request from server: {:?}", pad_req);
let response = pad.respond(pad_req.unwrap()).await.wrap_err("Error responding to pad request").unwrap();
if matches!(response, pad::PadResponse::EncoderValue(_)) {
send_to_server.send(response).await.map_err(|e| error!("Error sending response to server: {}", e)).ok();
}
}
}
}
Expand Down

0 comments on commit ea69fb0

Please # to comment.