stroke: stop enumerating IKE_SAs in statusall if output stream gets closed
authorMartin Willi <martin@revosec.ch>
Fri, 23 Aug 2013 12:22:29 +0000 (14:22 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 23 Aug 2013 12:27:17 +0000 (14:27 +0200)
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

index e81f3fc..7431514 100644 (file)
@@ -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);