From: Willy Tarreau Date: Tue, 1 Sep 2020 16:48:35 +0000 (+0200) Subject: MINOR: protocol: do not call proto->bind_all() anymore X-Git-Tag: v2.3-dev4~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94320859f9024e29791f097f550f57b67273326f;p=thirdparty%2Fhaproxy.git MINOR: protocol: do not call proto->bind_all() anymore All protocols only iterate over their own listeners list and start the listeners using a direct call to their ->bind() function. This code duplication doesn't make sense and prevents us from centralizing the startup error handling. Worse, it's not even symmetric because there's an unbind_all_listeners() function common to all protocols without any equivalent for binding. Let's start by directly calling each protocol's bind() function from protocol_bind_all(). --- diff --git a/src/protocol.c b/src/protocol.c index af13f42e78..faa634192d 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -57,14 +58,15 @@ void protocol_unregister(struct protocol *proto) int protocol_bind_all(char *errmsg, int errlen) { struct protocol *proto; + struct listener *listener; int err; err = 0; HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); list_for_each_entry(proto, &protocols, list) { - if (proto->bind_all) { - err |= proto->bind_all(proto, errmsg, errlen); - if ( err & ERR_ABORT ) + list_for_each_entry(listener, &proto->listeners, proto_list) { + err |= proto->bind(listener, errmsg, errlen); + if (err & ERR_ABORT) break; } }