--- libelwix/src/ring.c 2025/09/26 09:22:24 1.1.2.2 +++ libelwix/src/ring.c 2025/09/26 10:00:46 1.1.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: ring.c,v 1.1.2.2 2025/09/26 09:22:24 misho Exp $ +* $Id: ring.c,v 1.1.2.3 2025/09/26 10:00:46 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -161,7 +161,7 @@ rbuf_enqueue(ringbuf_t *rbuf, void *data, size_t len) int h, t, n; struct iovec *iov; - if (!rbuf) + if (!rbuf || !rbuf->rb_buffer) return -1; h = atomic_load_explicit(&rbuf->rb_head, memory_order_relaxed); @@ -191,7 +191,7 @@ rbuf_dequeue(ringbuf_t *rbuf, struct iovec *out) { int h, t, n; - if (!rbuf) + if (!rbuf || !rbuf->rb_buffer) return -1; h = atomic_load_explicit(&rbuf->rb_head, memory_order_acquire); @@ -202,7 +202,7 @@ rbuf_dequeue(ringbuf_t *rbuf, struct iovec *out) return 1; if (out) - out = rbuf->rb_buffer + t; + *out = rbuf->rb_buffer[t]; atomic_store_explicit(&rbuf->rb_tail, n, memory_order_release); return 0;