From 1a64d16720648ed918608536c5124dba1a34fdbf Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 28 Oct 2007 22:26:05 +0100 Subject: [PATCH] [MINOR] add a generic delete_listener() primitive Most protocols will be able to share a single delete_listener() primitive. Provide it in protocols.c, and remove the specific version from proto_uxst. --- include/proto/proto_uxst.h | 1 - include/proto/protocols.h | 7 +++++++ src/proto_uxst.c | 15 --------------- src/protocols.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/proto/proto_uxst.h b/include/proto/proto_uxst.h index dd5a40c5ef..642beb8cef 100644 --- a/include/proto/proto_uxst.h +++ b/include/proto/proto_uxst.h @@ -28,7 +28,6 @@ int uxst_event_accept(int fd); void uxst_add_listener(struct listener *listener); -void uxst_del_listener(struct listener *listener); void process_uxst_stats(struct task *t, struct timeval *next); #endif /* _PROTO_PROTO_UXST_H */ diff --git a/include/proto/protocols.h b/include/proto/protocols.h index 353e4c441c..c5efd0cad8 100644 --- a/include/proto/protocols.h +++ b/include/proto/protocols.h @@ -58,6 +58,13 @@ int disable_all_listeners(struct protocol *proto); */ int unbind_listener(struct listener *listener); +/* 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 + * been unbound. This is the generic function to use to remove a listener. + */ +void delete_listener(struct listener *listener); + /* Registers the protocol */ void protocol_register(struct protocol *proto); diff --git a/src/proto_uxst.c b/src/proto_uxst.c index ca00b3188f..0b3f317fc2 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -310,21 +310,6 @@ void uxst_add_listener(struct listener *listener) proto_unix.nb_listeners++; } -/* Delete a listener from the list of unix stream listeners. The listener's - * state is automatically updated from LI_ASSIGNED to LI_INIT. The number of - * listeners is updated. Note that the listener must have previously been - * unbound. This is the function to use to remove a listener. - */ -void uxst_del_listener(struct listener *listener) -{ - if (listener->state != LI_ASSIGNED) - return; - listener->state = LI_INIT; - LIST_DEL(&listener->proto_list); - proto_unix.nb_listeners--; -} - - /******************************** * 3) protocol-oriented functions ********************************/ diff --git a/src/protocols.c b/src/protocols.c index 3e118b822c..294edefa70 100644 --- a/src/protocols.c +++ b/src/protocols.c @@ -100,6 +100,20 @@ int unbind_listener(struct 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 + * been unbound. This is the generic function to use to remove a listener. + */ +void delete_listener(struct listener *listener) +{ + if (listener->state != LI_ASSIGNED) + return; + listener->state = LI_INIT; + LIST_DEL(&listener->proto_list); + listener->proto->nb_listeners--; +} + /* Registers the protocol */ void protocol_register(struct protocol *proto) { -- 2.47.2