]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables-monitor: Flush stdout after all lines of output
authorPhil Sutter <phil@nwl.cc>
Fri, 12 Jul 2024 11:03:18 +0000 (13:03 +0200)
committerPhil Sutter <phil@nwl.cc>
Sat, 27 Jul 2024 12:32:39 +0000 (14:32 +0200)
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

index cf92355f76f8aafbfb3412827d71870d26c52e6e..90d1cc5e37f319d52f681930f43f97b0606f2ab9 100644 (file)
@@ -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;
 }