]> git.meshlink.io Git - meshlink/commit - src/utcp.c
Handle UTCP receive buffer wraparound corner cases.
authorGuus Sliepen <guus@meshlink.io>
Fri, 15 May 2020 07:39:59 +0000 (09:39 +0200)
committerGuus Sliepen <guus@meshlink.io>
Fri, 15 May 2020 07:39:59 +0000 (09:39 +0200)
commitf13b47a184094c6c9c22faf22c4e6b1117a1d758
tree32e0b0d9468c2737547553d90fb67b70449dd4c4
parent306cfa82f27bc7fcf798e6bc35e58ea695ef7bf2
Handle UTCP receive buffer wraparound corner cases.

Before we allowed buf->offset to be equal to buf->size. This caused an
issue where buffer_call() would call the callback twice, once for 0
bytes at the end of the buffer, and once for len bytes at the start of
the buffer.  This would cause the callback function to think the channel
had encountered an error.

If the data in the ringbuffer wraps around, and we call the receive
callback for the first part of the data, the callback function might
close the channel, so we must not call the callback for the second part
of the data.
src/utcp.c