From: Willy Tarreau Date: Sun, 28 Oct 2007 21:35:41 +0000 (+0100) Subject: [MINOR] add a generic unbind_all_listeners() primitive X-Git-Tag: v1.3.14~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3acf8c3da849268a955d985630405c0d2fb2fff2;p=thirdparty%2Fhaproxy.git [MINOR] add a generic unbind_all_listeners() primitive Most protocols will be able to share a single unbind_all_listeners() primitive. Provide it in protocols.c. --- diff --git a/include/proto/protocols.h b/include/proto/protocols.h index c5efd0cad8..cd54ec8ee0 100644 --- a/include/proto/protocols.h +++ b/include/proto/protocols.h @@ -58,6 +58,12 @@ int disable_all_listeners(struct protocol *proto); */ int unbind_listener(struct listener *listener); +/* This function closes all listening sockets bound to the protocol , + * and the listeners end in LI_ASSIGNED state if they were higher. It does not + * detach them from the protocol. It always returns ERR_NONE. + */ +int unbind_all_listeners(struct protocol *proto); + /* Delete a listener from its protocol's list of listeners. The listener's * state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's * number of listeners is updated. Note that the listener must have previously diff --git a/src/protocols.c b/src/protocols.c index 294edefa70..70d04de4ca 100644 --- a/src/protocols.c +++ b/src/protocols.c @@ -100,6 +100,19 @@ int unbind_listener(struct listener *listener) return ERR_NONE; } +/* This function closes all listening sockets bound to the protocol , + * and the listeners end in LI_ASSIGNED state if they were higher. It does not + * detach them from the protocol. It always returns ERR_NONE. + */ +int unbind_all_listeners(struct protocol *proto) +{ + struct listener *listener; + + list_for_each_entry(listener, &proto->listeners, proto_list) + unbind_listener(listener); + return ERR_NONE; +} + /* Delete a listener from its protocol's list of listeners. The listener's * state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's * number of listeners is updated. Note that the listener must have previously