mirror of
https://github.com/D-Modem/gui.git
synced 2026-11-28 14:19:58 -08:00
ZMODEM receiver: a quiet line in a file is an error, not the end
When noise damaged the ZDLE before a subpacket's ZCRCQ (or a ZEOF), the sender waited for an answer that the receiver could not give, and the receiver gave up after 10 s of quiet. It now sends ZRPOS, as for a bad CRC, and gives up only after 4 quiet waits in a row. Found by CI on the zstd noisy test; 49 noisy runs at 1 in 2000 to 1 in 3200 now all pass (before, the first two failed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRR1WNeCEtXUcjE8RgY
This commit is contained in:
1 file changed
+12
-3
+12
-3
@@ -647,7 +647,7 @@ static int receive_file(struct z *z, const unsigned char *info, int len, int f0,
|
||||
xfer_file_start(x, x->dst_name, size);
|
||||
xfer_bytes(x, pos);
|
||||
xfer_zstd(x, zstd);
|
||||
int errors = 0, ok = 0;
|
||||
int errors = 0, ok = 0, quiet = 0;
|
||||
struct header h;
|
||||
/* (until the sender has had time to hear our ZRPOS, what still comes
|
||||
of its stream from before isn't an error, and isn't asked for
|
||||
@@ -667,7 +667,9 @@ static int receive_file(struct z *z, const unsigned char *info, int len, int f0,
|
||||
/* (8 KB of a stream with no header in it: ours lost; asked
|
||||
for again) */
|
||||
int st = read_header(z, 8 * 1024, 1, &h);
|
||||
if (st == H_QUIET)
|
||||
/* (quiet: what the sender waits on lost, a ZDATA's end or a
|
||||
ZEOF; asked for again, as for an error, a few times) */
|
||||
if (st == H_QUIET && ++quiet > 3)
|
||||
xfer_fail(x, "the other side went quiet");
|
||||
if (st != H_OK) {
|
||||
if (WAITING())
|
||||
@@ -677,6 +679,7 @@ static int receive_file(struct z *z, const unsigned char *info, int len, int f0,
|
||||
RPOS();
|
||||
continue;
|
||||
}
|
||||
quiet = 0;
|
||||
if (h.type == ZDATA) {
|
||||
if (hpos(&h) != pos) {
|
||||
/* not where we are: back to it (not an error) */
|
||||
@@ -688,7 +691,12 @@ static int receive_file(struct z *z, const unsigned char *info, int len, int f0,
|
||||
for (;;) {
|
||||
int end;
|
||||
long long wrote = 0;
|
||||
int n = read_data_or_fail(z, 8192, &end);
|
||||
/* (the line quiet in the middle of a subpacket: its
|
||||
end damaged, and the sender waits for an ACK of
|
||||
it; an error, asked for again) */
|
||||
int n = read_data(z, 8192, &end);
|
||||
if (n == -2 && ++quiet > 3)
|
||||
xfer_fail(x, "the other side went quiet");
|
||||
if (n >= 0 && zstd) {
|
||||
/* (the whole frames written, even when
|
||||
one after them is bad) */
|
||||
@@ -709,6 +717,7 @@ static int receive_file(struct z *z, const unsigned char *info, int len, int f0,
|
||||
pos += n;
|
||||
}
|
||||
errors = 0;
|
||||
quiet = 0;
|
||||
xfer_bytes(x, pos);
|
||||
if (end == ZCRCW) {
|
||||
send_hex(z, hdr_pos(ZACK, pos));
|
||||
|
||||
Reference in new issue
Block a user