]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEV: haring: automatically use the advertised ring header size
authorWilly Tarreau <w@1wt.eu>
Mon, 4 Mar 2024 18:15:59 +0000 (19:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 9 Mar 2024 10:23:52 +0000 (11:23 +0100)
Instead of emitting a warning, since we don't need the ring struct
anymore, we can just read what we need, parse the buffer and use the
advertised offset. Thus for now -f is simply ignored.

dev/haring/haring.c

index 628f223b30dced2fc35154fa00f271b8df2aeac9..724e598b93e72c84b11dd6e867d81f055165291e 100644 (file)
@@ -44,9 +44,6 @@ int repair = 0; // repair file
 
 struct ring_v1 {
        struct buffer buf;   // storage area
-       struct list waiters; // list of waiters, for now, CLI "show event"
-       __decl_thread(HA_RWLOCK_T lock);
-       int readers_count;
 };
 
 /* display the message and exit with the code */
@@ -160,14 +157,8 @@ int dump_ring_as_buf(struct buffer buf, size_t ofs, int flags)
        return 0;
 }
 
-/* This function dumps all events from the ring whose pointer is in <p0> into
- * the appctx's output buffer, and takes from <o0> the seek offset into the
- * buffer's history (0 for oldest known event). It looks at <i0> for boolean
- * options: bit0 means it must wait for new data or any key to be pressed. Bit1
- * means it must seek directly to the end to wait for new contents. It returns
- * 0 if the output buffer or events are missing is full and it needs to be
- * called again, otherwise non-zero. It is meant to be used with
- * cli_release_show_ring() to clean up.
+/* This function dumps all events from the ring <ring> from offset <ofs> and
+ * with flags <flags>.
  */
 int dump_ring_v1(struct ring_v1 *ring, size_t ofs, int flags)
 {
@@ -181,20 +172,6 @@ int dump_ring_v1(struct ring_v1 *ring, size_t ofs, int flags)
         * run a few checks first. After that we'll create our own buffer
         * descriptor matching that area.
         */
-       if ((((long)ring->buf.area) & 4095) != sizeof(*ring)) {
-               if (!force) {
-                       fprintf(stderr, "FATAL: header in file is %ld bytes long vs %ld expected!\n",
-                               (((long)ring->buf.area) & 4095),
-                               (long)sizeof(*ring));
-                       exit(1);
-               }
-               else {
-                       fprintf(stderr, "WARNING: header in file is %ld bytes long vs %ld expected!\n",
-                               (((long)ring->buf.area) & 4095),
-                               (long)sizeof(*ring));
-               }
-               /* maybe we could emit a warning at least ? */
-       }
 
        /* Now make our own buffer pointing to that area */
        buf = b_make(((void *)ring + (((long)ring->buf.area) & 4095)),