diff mbox series

[iptables,2/8] xtables-monitor: Flush stdout after all lines of output

Message ID 20240716122805.22331-3-phil@nwl.cc
State Accepted
Headers show
Series Fix xtables-monitor rule printing, partially RFC | expand

Commit Message

Phil Sutter July 16, 2024, 12:27 p.m. UTC
Writing an xtables-monitor testsuite is pretty much impossible without
this due to unreliable output flushing. Just move the fflush() call from
trace_cb() to its caller so monitor events benefit from it as well.

Fixes: 07af4da52ab30 ("xtables-monitor: fix rule printing")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/xtables-monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/iptables/xtables-monitor.c b/iptables/xtables-monitor.c
index cf92355f76f8a..90d1cc5e37f31 100644
--- a/iptables/xtables-monitor.c
+++ b/iptables/xtables-monitor.c
@@ -544,7 +544,6 @@  static int trace_cb(const struct nlmsghdr *nlh, struct cb_arg *arg)
 err_free:
 	nftnl_trace_free(nlt);
 err:
-	fflush(stdout);
 	return MNL_CB_OK;
 }
 
@@ -576,6 +575,7 @@  static int monitor_cb(const struct nlmsghdr *nlh, void *data)
 		break;
 	}
 
+	fflush(stdout);
 	return ret;
 }