]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: list: define watcher_is_attached()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 4 Aug 2026 14:54:19 +0000 (16:54 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 5 Aug 2026 09:36:20 +0000 (11:36 +0200)
Define an utility function to report if a watcher is currently attached
on a target. This will notably be used to implement a new CLI command
"show default-server".

include/haproxy/list.h

index 95cc78a75007510a0022abf902d3b7e1c9b42c4f..e4c75dc6f1921702c4fbe6b29afdf65022fe5959 100644 (file)
@@ -272,6 +272,12 @@ static __inline void watcher_init(struct watcher *w, void *pptr, size_t attach_o
        w->off = attach_off;
 }
 
+/* Returns true if <w> is currently tracking a target else false. */
+static __inline int watcher_is_attached(const struct watcher *w)
+{
+       return MT_LIST_INLIST(&w->el);
+}
+
 /* Tracks <target> via <w> watcher. Invalid if <w> is already attached. */
 static __inline void watcher_attach(struct watcher *w, void *target)
 {