more breadcrumbs
This commit is contained in:
@@ -123,6 +123,7 @@ impl Drop for SimpleCallOnReturn {
|
||||
|
||||
pub fn global_init() -> bool {
|
||||
install_panic_hook();
|
||||
install_heartbeat();
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if !crate::platform::linux::is_x11() {
|
||||
@@ -132,6 +133,27 @@ pub fn global_init() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Background thread that logs a heartbeat every second. Used purely to pin
|
||||
/// down silent process exits — if the heartbeat stops, the process died at
|
||||
/// that timestamp, and we can correlate with what other threads were doing.
|
||||
/// Uses a counter so we can also tell if logging itself is wedged (counter
|
||||
/// keeps incrementing) vs the whole process is gone (no more lines).
|
||||
fn install_heartbeat() {
|
||||
use std::sync::Once;
|
||||
static INIT: Once = Once::new();
|
||||
INIT.call_once(|| {
|
||||
std::thread::spawn(|| {
|
||||
let pid = std::process::id();
|
||||
let mut tick: u64 = 0;
|
||||
loop {
|
||||
tick += 1;
|
||||
log::info!("heartbeat: pid={pid} tick={tick}");
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Capture Rust panics so they survive the windows-subsystem build.
|
||||
///
|
||||
/// In release we have `panic = 'abort'` and `windows_subsystem = "windows"`,
|
||||
|
||||
@@ -219,10 +219,14 @@ impl RendezvousMediator {
|
||||
};
|
||||
select! {
|
||||
n = socket.next() => {
|
||||
log::info!("breadcrumb: udp socket.next() returned");
|
||||
match n {
|
||||
Some(Ok((bytes, _))) => {
|
||||
log::info!("breadcrumb: udp packet received, {} bytes", bytes.len());
|
||||
if let Ok(msg) = Message::parse_from_bytes(&bytes) {
|
||||
log::info!("breadcrumb: before handle_resp");
|
||||
rz.handle_resp(msg.union, Sink::Framed(&mut socket, &addr), &server, &mut update_latency).await?;
|
||||
log::info!("breadcrumb: after handle_resp");
|
||||
} else {
|
||||
log::debug!("Non-protobuf message bytes received: {:?}", bytes);
|
||||
}
|
||||
@@ -234,6 +238,7 @@ impl RendezvousMediator {
|
||||
}
|
||||
},
|
||||
_ = timer.tick() => {
|
||||
log::info!("breadcrumb: udp timer.tick()");
|
||||
if SHOULD_EXIT.load(Ordering::SeqCst) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user