From: Willy Tarreau Date: Fri, 9 Aug 2024 19:32:29 +0000 (+0200) Subject: MINOR: protocol: always initialize the receivers list on registration X-Git-Tag: v3.1-dev6~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1cb3b0b745fc6288da33fc6b01cb6ae154863793;p=thirdparty%2Fhaproxy.git MINOR: protocol: always initialize the receivers list on registration Till now, protocols were required to self-initialize their receivers list head, which is not very convenient, and is quite error prone. Indeed, it's too easy to copy-paste a protocol definition and forget to update the .receivers field to point to itself, resulting in mixed lists. Let's just do that in protocol_register(). And while we're at it, let's also zero the nb_receivers entry that works with it, so that the protocol definition isn't required to pre-initialize stuff related to internal book-keeping. --- diff --git a/src/protocol.c b/src/protocol.c index 516c020d1c..f5f4940685 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -44,6 +44,9 @@ void protocol_register(struct protocol *proto) BUG_ON(sock_family < 0 || sock_family >= AF_CUST_MAX); BUG_ON(proto->proto_type >= PROTO_NUM_TYPES); + LIST_INIT(&proto->receivers); + proto->nb_receivers = 0; + HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); LIST_APPEND(&protocols, &proto->list); __protocol_by_family[sock_family]