diff options
-rw-r--r-- | utils/ring.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/ring.h b/utils/ring.h index cc93b87fc..587240ce0 100644 --- a/utils/ring.h +++ b/utils/ring.h @@ -106,6 +106,23 @@ } while (p != ring); \ } else sizevar = 0 +/** Count the number of elements in the ring which match the provided lwc_hostname */ +#define RING_COUNTBYLWCHOST(ringtype, ring, sizevar, lwc_hostname) \ + /*LOG(("RING_COUNTBYHOST(%s, %s)", #ring, hostname));*/ \ + if (ring) { \ + ringtype *p = ring; \ + sizevar = 0; \ + do { \ + bool matches = false; \ + if (lwc_string_caseless_isequal(p->lwc_host, \ + lwc_hostname, \ + &matches) == lwc_error_ok) \ + if (matches) \ + sizevar++; \ + p = p->r_next; \ + } while (p != ring); \ + } else sizevar = 0 + /* * Ring iteration works as follows: * |