From: Martin Willi Date: Fri, 23 Aug 2013 12:22:29 +0000 (+0200) Subject: stroke: stop enumerating IKE_SAs in statusall if output stream gets closed X-Git-Tag: 5.1.1dr2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49032d15be34cdb0ba9f233e837e3949ee14067c;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/src/libcharon/plugins/stroke/stroke_list.c b/src/libcharon/plugins/stroke/stroke_list.c index e81f3fc324..7431514b6f 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);