Skip to content

Commit

Permalink
Migrate to a schedule based polling strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Sep 30, 2024
1 parent 7168101 commit 95a4c4e
Show file tree
Hide file tree
Showing 9 changed files with 1,057 additions and 795 deletions.
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trace-recorder-rtt-proxy"
version = "0.10.0"
version = "0.11.0"
edition = "2021"
authors = ["Jon Lamb <[email protected]>"]
description = "Proxy debug-probe operations and trace recorder RTT data over the network"
Expand All @@ -21,7 +21,7 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
exitcode = "1"
thiserror = "1"
parking_lot = "0.12"
crossbeam-channel = "0.5"
serde_json = "1.0"
serde = { version = "1.0", features=["derive"] }
derive_more = { version = "1", features = ["display"] }
Expand Down
8 changes: 6 additions & 2 deletions examples/trc-rtt-proxy-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn do_main() -> Result<(), Box<dyn std::error::Error>> {
let mut file = File::open(elf_file)?;
if let Some(rtt_addr) = get_rtt_symbol(&mut file) {
info!(
rtt_addr = format_args!("0x:{:X}", rtt_addr),
rtt_addr = format_args!("0x{:X}", rtt_addr),
"Found RTT symbol"
);
Some(rtt_addr)
Expand Down Expand Up @@ -359,7 +359,11 @@ fn start_session_retry_loop(
while Instant::now().duration_since(start) <= timeout {
match start_session(remote, cfg) {
Ok(s) => return Ok(s),
Err(_) => continue,
Err(e) => {
debug!(error = %e, "Failed to start session");
std::thread::sleep(Duration::from_millis(100));
continue;
}
}
}
start_session(remote, cfg)
Expand Down
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::interruptor::Interruptor;
use clap::Parser;
use probe_rs::probe::list::Lister;
use std::{
net::{SocketAddr, TcpListener},
sync::mpsc,
};
use std::net::{SocketAddr, TcpListener};
use tracing::{debug, error, info};

mod interruptor;
mod manager;
mod rate_limiter;
mod rtt_session;
mod server;
mod shared_state;
mod trc_command;

/// Proxy debug-probe operations and RTT data over the network
Expand Down Expand Up @@ -57,11 +56,12 @@ fn do_main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_thread_ids(false)
.with_thread_names(true)
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ENTER)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.compact()
.init();

let (op_tx, op_rx) = mpsc::sync_channel(manager::Operation::OPERATION_CHANNEL_SIZE);
let (op_tx, op_rx) = crossbeam_channel::bounded(manager::Operation::OPERATION_CHANNEL_SIZE);

let intr = Interruptor::new();
let handler_op_tx = op_tx.clone();
Expand Down Expand Up @@ -109,5 +109,7 @@ fn do_main() -> Result<(), Box<dyn std::error::Error>> {
// Wait for the manager thread to finish
manager_handle.join().ok();

info!("Shutdown complete");

Ok(())
}
Loading

0 comments on commit 95a4c4e

Please sign in to comment.