MINOR: ring: make sure ring_dispatch waits when facing a changing message
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.
This commit is contained in:
parent
31b93b40b0
commit
cb482f92c4
@ -513,6 +513,12 @@ int ring_dispatch_messages(struct ring *ring, void *ctx, size_t *ofs_ptr, size_t
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user