From 49032d15be34cdb0ba9f233e837e3949ee14067c Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 23 Aug 2013 14:22:29 +0200 Subject: [PATCH] stroke: stop enumerating IKE_SAs in statusall if output stream gets closed If the output stream is not interested in more information, it can close the the stream. Checking for stream errors avoids useless enumeration of IKE_SAs, saving resources. This allows to use "ipsec statusall | head" to monitor the daemon, or stop enumerating IKE_SAs after a specific entry has been found. --- src/libcharon/plugins/stroke/stroke_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcharon/plugins/stroke/stroke_list.c b/src/libcharon/plugins/stroke/stroke_list.c index e81f3fc32..7431514b6 100644 --- a/src/libcharon/plugins/stroke/stroke_list.c +++ b/src/libcharon/plugins/stroke/stroke_list.c @@ -647,7 +647,7 @@ METHOD(stroke_list_t, status, void, half_open); enumerator = charon->controller->create_ike_sa_enumerator( charon->controller, wait); - while (enumerator->enumerate(enumerator, &ike_sa)) + while (enumerator->enumerate(enumerator, &ike_sa) && ferror(out) == 0) { bool ike_printed = FALSE; enumerator_t *children = ike_sa->create_child_sa_enumerator(ike_sa);