From 2c0f8292c67de1450e0e74fd1d0819ad33668e00 Mon Sep 17 00:00:00 2001
From: "J. Burfeind" <git@aiyionpri.me>
Date: Mon, 15 Mar 2021 17:52:34 +0100
Subject: [PATCH] gluon-neighbour-info: end before timeout (#2185)

End the process after one result in case -l is not given
and destination address is unicast.
Reduces singleshot execution time from timeout seconds to around 150ms.

resolves #2184
---
 package/gluon-neighbour-info/src/gluon-neighbour-info.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/gluon-neighbour-info/src/gluon-neighbour-info.c b/package/gluon-neighbour-info/src/gluon-neighbour-info.c
index 6e255d874..6470508cc 100644
--- a/package/gluon-neighbour-info/src/gluon-neighbour-info.c
+++ b/package/gluon-neighbour-info/src/gluon-neighbour-info.c
@@ -44,7 +44,8 @@ void usage() {
 	puts("  -t <sec>         timeout in seconds (default: 3)");
 	puts("  -s <event>       output as server-sent events of type <event>");
 	puts("                   or without type if <event> is the empty string");
-	puts("  -c <count>       only wait for at most <count> replies");
+	puts("  -c <count>       only wait for at most <count> replies (default: 1");
+	puts("                   if -l is not given for unicast destination addresses)");
 	puts("  -l               after timeout (or <count> replies if -c is given),");
 	puts("                   send another request and loop forever");
 	puts("  -h               this help\n");
@@ -232,6 +233,10 @@ int main(int argc, char **argv) {
 		}
 	}
 
+	if (!loop && !IN6_IS_ADDR_MULTICAST(&client_addr.sin6_addr)) {
+		max_count=1;
+	}
+
 	if (sse) {
 		fputs("Content-Type: text/event-stream\n\n", stdout);
 		fflush(stdout);
-- 
GitLab