nasa / bplib

Apache License 2.0
30 stars 13 forks source link

bpcat should not increment stream position if bplib_send fails #158

Closed jphickey closed 2 years ago

jphickey commented 2 years ago

There are various conditions, notably when low on memory, where bplib_send() can fail or time out.

By design, when this happens, bpcat should not read any more new data, but keep trying until it succeeds (such as if the CLA side drains enough out and some memory gets freed). However, the "stream_pos" variable will get updated each time it retries, leaving an incorrect value in the bundle that finally gets sent. This value should only be updated on the first attempt, not on subsequent attempts to send the same data.

There are also some debug messages that could be improved which would show the activity around this more clearly (i.e. including the position in the debug messages).

jphickey commented 2 years ago

This is a bug, because if the bpcat program needs to repeat the call to bplib_send() for any reason, the receiver is not able to correctly reassemble the file - it sees a gap.