From: Rafał Miłecki Date: Fri, 10 Feb 2017 11:58:24 +0000 (+0100) Subject: Move matching logic out of service_reply_single function X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a069fbbd11394ec5b8a32e28ff9b6c9d8d6b07c4;p=oweals%2Fmdnsd.git Move matching logic out of service_reply_single function There is only 1 place in project calling this function with the match argument. It's easier to add prooper condition in this place and have service_reply_single simplified by taking 1 less argument. Signed-off-by: Rafał Miłecki --- diff --git a/service.c b/service.c index f45784b..182b2b2 100644 --- a/service.c +++ b/service.c @@ -118,7 +118,7 @@ service_timeout(struct service *s) } static void -service_reply_single(struct interface *iface, struct service *s, const char *match, int ttl, int force) +service_reply_single(struct interface *iface, struct service *s, int ttl, int force) { const char *host = service_name(s->service); char *service = strstr(host, "._"); @@ -130,9 +130,6 @@ service_reply_single(struct interface *iface, struct service *s, const char *mat service++; - if (match && strcmp(match, s->service)) - return; - s->t = t; dns_init_answer(); @@ -151,8 +148,10 @@ service_reply(struct interface *iface, const char *match, int ttl) { struct service *s; - vlist_for_each_element(&services, s, node) - service_reply_single(iface, s, match, ttl, 0); + vlist_for_each_element(&services, s, node) { + if (!match || !strcmp(s->service, match)) + service_reply_single(iface, s, ttl, 0); + } } void @@ -203,7 +202,7 @@ service_update(struct vlist_tree *tree, struct vlist_node *node_new, if (service_init_announce) vlist_for_each_element(&interfaces, iface, node) { s->t = 0; - service_reply_single(iface, s, NULL, announce_ttl, 1); + service_reply_single(iface, s, announce_ttl, 1); } return; } @@ -211,7 +210,7 @@ service_update(struct vlist_tree *tree, struct vlist_node *node_new, s = container_of(node_old, struct service, node); if (!node_new && service_init_announce) vlist_for_each_element(&interfaces, iface, node) - service_reply_single(iface, s, NULL, 0, 1); + service_reply_single(iface, s, 0, 1); free(s); }