some more optimizations

This commit is contained in:
2024-04-29 16:45:08 +02:00
parent e227fa1d01
commit a095132d57
3 changed files with 28 additions and 15 deletions

View File

@ -145,6 +145,16 @@ impl TcpSppClientStd {
}
pub fn operation(&mut self) -> Result<ClientResult, ClientError> {
let result = self.operation_inner();
if let Ok(client_result) = &result {
if *client_result != ClientResult::Ok {
std::thread::sleep(self.read_and_idle_delay);
}
}
result
}
fn operation_inner(&mut self) -> Result<ClientResult, ClientError> {
if let Some(client) = &mut self.stream {
// Write TM first before blocking on the read call.
self.common.write_to_server(client)?;

View File

@ -24,10 +24,7 @@ use satrs::{
pus::event_man::EventRequestWithToken,
};
use crate::{
controller::ControllerPathCollection, interface::tcp_spp_client::ClientResult,
tmtc::tm_sink::TmFunnelDynamic,
};
use crate::{controller::ControllerPathCollection, tmtc::tm_sink::TmFunnelDynamic};
use crate::{controller::ExperimentController, pus::test::create_test_service};
use crate::{
events::EventHandler,
@ -284,13 +281,7 @@ fn main() {
info!("Running TCP SPP client");
loop {
match tcp_spp_client.operation() {
Ok(result) => {
// If the client connection was processed regularly, the read timeout takes
// care of the sleep time.
if result != ClientResult::Ok {
std::thread::sleep(STOP_CHECK_FREQUENCY);
}
}
Ok(_result) => (),
Err(e) => {
log::error!("TCP SPP client error: {}", e);
}