As Eric pointed out, fflush() only makes sense in monitor mode.
In other modes buffering the output helps with large outputs
like route dumps.
Move the fflush() into rtnl_listen() which is the common code
used by all monitoring subcommands. This also ensures any future
monitor subcommand gets correct flushing behavior automatically.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
print_string(PRINT_ANY, "state", "%s\n",
state_n2a(r->ndm_state));
close_json_object();
- fflush(fp);
return 0;
}
exit(1);
}
delete_json_obj();
- fflush(stdout);
return 0;
}
print_string(PRINT_FP, NULL, "%s", "\n");
close_json_object();
- fflush(fp);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
close_json_object();
delete_json_obj();
- fflush(stdout);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
struct if_stats_msg *ifsm = NLMSG_DATA(n);
struct rtattr *tb[IFLA_STATS_MAX+1];
int len = n->nlmsg_len;
- FILE *fp = arg;
len -= NLMSG_LENGTH(sizeof(*ifsm));
if (len < 0) {
print_vlan_stats_attr(tb[IFLA_STATS_LINK_XSTATS_SLAVE],
ifsm->ifindex);
- fflush(fp);
return 0;
}
out:
delete_json_obj();
- fflush(stdout);
return 0;
}
close_vlan_port();
delete_json_obj();
- fflush(stdout);
return 0;
}
if (opened)
close_vni_port();
- fflush(stdout);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
struct genlmsghdr *ghdr = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr *attrs;
- FILE *fp = (FILE *) arg;
if (n->nlmsg_type != GENL_ID_CTRL) {
fprintf(stderr, "Not a controller message, nlmsg_len=%d "
if (tb[CTRL_ATTR_MCAST_GROUPS])
print_ctrl_mcast(tb[CTRL_ATTR_MCAST_GROUPS]);
- fflush(fp);
return 0;
}
print_string(PRINT_FP, NULL, "%s", "\n");
}
- fflush(fp);
return 0;
}
}
print_string(PRINT_FP, NULL, "%s", "\n");
- fflush(fp);
/* prettier here if stderr and stdout go to the same place */
if (truncated_vfs)
fprintf(stderr, "Truncated VF list: %s\n", name);
}
print_string(PRINT_FP, NULL, "%s", "\n");
brief_exit:
- fflush(fp);
return 0;
}
if (brief) {
print_string(PRINT_FP, NULL, "%s", "\n");
- fflush(fp);
}
return 0;
}
print_link_stats(stdout, n);
close_json_object();
}
- fflush(stdout);
out:
free_nlmsg_chain(ainfo);
return 1;
}
delete_json_obj();
- fflush(stdout);
return 0;
}
return 1;
}
delete_json_obj();
- fflush(stdout);
return 0;
}
exit(1);
}
delete_json_obj();
- fflush(stdout);
}
return 0;
exit(1);
}
delete_json_obj();
- fflush(stdout);
return 0;
}
exit(1);
}
delete_json_obj();
- fflush(stdout);
return 0;
}
print_nl();
print_mpls_link_stats(fp, stats, " ");
print_string(PRINT_FP, NULL, "%s", "\n");
- fflush(fp);
}
static void print_af_stats_attr(FILE *fp, int ifindex, struct rtattr *attr)
if (tb[IFLA_STATS_AF_SPEC])
print_af_stats_attr(fp, ifsm->ifindex, tb[IFLA_STATS_AF_SPEC]);
- fflush(fp);
return 0;
}
print_nl();
close_json_object();
- fflush(stdout);
return 0;
}
if (rtnl_dump_filter(&genl_rth, print_mptcp_addr, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
delete_json_obj();
- fflush(stdout);
return -2;
}
delete_json_obj();
- fflush(stdout);
return 0;
}
ret = print_mptcp_addr(answer, stdout);
delete_json_obj();
free(answer);
- fflush(stdout);
return ret;
}
print_nl();
close_json_object();
- fflush(stdout);
return 0;
}
out:
print_nl();
close_json_object();
- fflush(stdout);
return 0;
}
print_string(PRINT_FP, NULL, "\n", NULL);
close_json_object();
- fflush(fp);
return 0;
}
print_string(PRINT_FP, NULL, "%s", "\n");
close_json_object();
- fflush(fp);
return 0;
}
print_string(PRINT_FP, NULL, "\n", "");
close_json_object();
- fflush(fp);
return 0;
}
close_json_object();
print_string(PRINT_FP, NULL, "\n", NULL);
- fflush(fp);
return 0;
}
print_string(PRINT_FP, NULL, "\n", NULL);
close_json_object();
- fflush(fp);
return 0;
}
__print_nexthop_entry(fp, NULL, &nhe, n->nlmsg_type == RTM_DELNEXTHOP);
print_string(PRINT_FP, NULL, "%s", "\n");
- fflush(fp);
if (process_cache)
ipnh_cache_process_nlmsg(n, &nhe);
print_string(PRINT_FP, NULL, "%s", "\n");
close_json_object();
- fflush(fp);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
free(answer);
}
delete_json_obj();
- fflush(stdout);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
free(answer);
static int print_ntable(struct nlmsghdr *n, void *arg)
{
- FILE *fp = (FILE *)arg;
struct ndtmsg *ndtm = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr *tb[NDTA_MAX+1];
print_string(PRINT_FP, NULL, "\n", "");
close_json_object();
- fflush(fp);
return 0;
}
}
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
print_string(PRINT_FP, NULL, "\n", NULL);
close_json_object();
- fflush(fp);
return 0;
}
if (time(0) - start > 30) {
printf("\n*** Flush not completed after %ld seconds, %d entries remain ***\n",
(long)(time(0) - start), filter.flushed);
+ fflush(stdout);
return -1;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
print_string(PRINT_FP, NULL, "\n", "");
close_json_object();
- fflush(fp);
return 0;
}
exit(1);
}
delete_json_obj();
- fflush(stdout);
}
return 0;
rc = -2;
}
- fflush(stdout);
return rc;
}
if (rc)
return rc;
- fflush(fp);
return 0;
}
static int print_token(struct nlmsghdr *n, void *arg)
{
struct rtnl_dump_args *args = arg;
- FILE *fp = args->fp;
int ifindex = args->ifindex;
struct ifinfomsg *ifi = NLMSG_DATA(n);
int len = n->nlmsg_len;
"ifname", "%s\n",
ll_index_to_name(ifi->ifi_index));
close_json_object();
- fflush(fp);
return 0;
}
}
delete_json_obj();
- fflush(stdout);
return 0;
}
static int process_msg(struct nlmsghdr *n, void *arg)
{
- FILE *fp = (FILE *) arg;
struct genlmsghdr *ghdr;
struct rtattr *attrs[TCP_METRICS_ATTR_MAX + 1], *a;
const char *h;
print_string(PRINT_FP, NULL, "\n", "");
close_json_object();
- fflush(fp);
return 0;
}
if (oneline)
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
if (oneline)
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
if (oneline)
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
xfrm_usersa_print(&id->sa_id, id->reqid, fp);
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
xfrm_usersa_print(&map->id, map->reqid, fp);
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
if (oneline)
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
fprintf(fp, " in: %s\n", xfrm_policy_to_str(up->in));
fprintf(fp, " fwd: %s\n", xfrm_policy_to_str(up->fwd));
fprintf(fp, " out: %s\n", xfrm_policy_to_str(up->out));
- fflush(fp);
return 0;
}
if (oneline)
fprintf(fp, "\n");
- fflush(fp);
return 0;
}
}
err = handler(&ctrl, h, jarg);
+ fflush(stdout);
if (err < 0)
return err;
close_json_object();
}
close_json_object();
- fflush(fp);
return 0;
}
print_ext_msg(tb);
close_json_object();
- fflush(fp);
return 0;
}
print_ext_msg(tb);
close_json_object();
- fflush(fp);
return 0;
}