The writer is using tags 0xFF instead of readers count at the front of
messages that are undergoing an update, while the tail has already been
updated. The reader needs to take care of this because it can face these
messages and mistakenly parse data that's still being written, leading
to corruption (especially if this happens while the size is changing).
Let's just stop reading when facing reserved codes, since they indicate
that the end of usable messages was reached.
break;
}
+ readers = _HA_ATOMIC_LOAD(_vp_addr(v1, v2, 0));
+ if (readers > RING_MAX_READERS) {
+ /* we just met a writer which hasn't finished */
+ break;
+ }
+
cnt = 1;
len = vp_peek_varint_ofs(v1, v2, cnt, &msg_len);
if (!len)