Add --log/--remote-log diagnostic tracing for stalled transfers

Adds an optional timestamped trace of transfer-relevant events (tail
position vs. file length, rename detection, finalize, protocol
send/recv) to both the client and server sides, so a stalled transfer
can be diagnosed from correlated local/remote logs instead of guessing.

Notably logs when a source's final size ends up smaller than what was
already read (pos > current_len after rename) -- this can never
satisfy the pos == current_len finalize condition, which is a real
deadlock risk for writers that preallocate a fixed-size file and
truncate down to the actual capture length before renaming.

--log <path> on either the client or `--server` process traces that
process's own events. --log on ClientCli is local-only; --remote-log
<path> is forwarded as the spawned --server process's --log so both
sides of a remote transfer leave a trace, tied together by timestamp.
This commit is contained in:
eric committed 2026-08-27 17:06:00 -04:00
1 parent 17e9e5e361
commit b3e7248ac5
7 files changed
+189 -14

No files matched your search

+17
View File
@@ -32,6 +32,18 @@ pub struct ClientCli {
/// Path to the scpcap executable on the remote host, e.g. `~/bin/scpcap`.
#[arg(long, default_value = "scpcap")]
pub remote_exe: String,
/// Append a diagnostic trace of this (local) process's transfer events
/// to this file -- positions, rename detection, finalize -- for
/// figuring out where a stalled transfer is stuck.
#[arg(long, value_name = "PATH")]
pub log: Option<String>,
/// Path (on the remote host) to pass as the spawned `--server`
/// process's own `--log`, so both sides of a remote transfer leave a
/// trace. Ignored for local-to-local transfers.
#[arg(long, value_name = "PATH")]
pub remote_log: Option<String>,
}
/// Remote helper mode, ssh-spawned by the client (like `rsync --server`).
@@ -75,6 +87,11 @@ pub struct ServerCli {
/// Destination temp path, written while in flight (--recv mode).
#[arg(long)]
pub dest_temp: Option<String>,
/// Append a diagnostic trace of this (remote) process's transfer events
/// to this file. See the client's `--log`/`--remote-log`.
#[arg(long, value_name = "PATH")]
pub log: Option<String>,
}
/// The clap-facing shape of the role choice: two mutually exclusive,