Commit 4528018
authored
fix(xmodem): close the file when a transmit is aborted (#11598)
The `else if (isTransmitting)` branch in handlePacket() cancels the
transfer and clears isTransmitting without closing the open file. It is
the only terminal path that does not close: EOT, CAN, and the ACK/EOT
completion paths all do. The next transmit then reassigns `file` in the
STX handler, orphaning the previous handle.
Any client that can speak the XModem ToRadio path can drive this in a
loop (STX seq=0 to start a transmit, then any non-seq-0 frame to hit the
abort branch), and XModem is not subject to the PhoneAPI packet
throttle, so the loop runs as fast as the link allows.
Measured on real hardware with a DEBUG_HEAP build, 60 iterations:
Heltec Mesh Node T096 (nRF52840) 44,908 -> 32,896 B free (-200 B/iter)
Heltec Wireless Tracker V2 (S3) 57,360 -> 51,472 B free ( -98 B/iter)
The heap is not reclaimed afterwards. On the T096 that exhausts ~45 KB
of free heap in roughly 225 iterations.
With this change, 200 iterations on a T096 leave free heap unchanged
(44,968 B before and after).1 parent 4835753 commit 4528018
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
| |||
0 commit comments