#include <haproxy/thread.h>
/* The code below handles circular buffers with single-producer and multiple
- * readers (up to 255). The buffer storage area must remain always allocated.
+ * readers (up to 254). The buffer storage area must remain always allocated.
* It's made of series of payload blocks followed by a readers count (RC).
* There is always a readers count at the beginning of the buffer as well. Each
* payload block is composed of a varint-encoded size (VI) followed by the
#define RING_WF_WAIT_MODE 0x00000001 /* wait for new contents */
#define RING_WF_SEEK_NEW 0x00000002 /* seek to new contents */
+/* keep values below in decimal, they may be dumped in error messages */
+#define RING_WRITING_SIZE 255 /* the next message's size is being written */
+#define RING_MAX_READERS 254 /* highest supported value for RC */
+
struct ring {
struct buffer buf; // storage area
struct list waiters; // list of waiters, for now, CLI "show event"
int users = ring->readers_count;
do {
- if (users >= 255)
+ if (users >= RING_MAX_READERS)
return 0;
} while (!_HA_ATOMIC_CAS(&ring->readers_count, &users, users + 1));
return 1;
if (!ring_attach(ring))
return cli_err(appctx,
- "Sorry, too many watchers (255) on this ring buffer. "
+ "Sorry, too many watchers (" TOSTR(RING_MAX_READERS) ") on this ring buffer. "
"What could it have so interesting to attract so many watchers ?");
if (!appctx->io_handler)