From 9d8271036d7db5d6900ef16a39930d7ae13a3e15 Mon Sep 17 00:00:00 2001 From: enometh <57609820+enometh@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:42:35 +0530 Subject: [PATCH] pppd: Fix reliability of print_link_stats (with option persist) (#505) * pppd/ipcp.c: (ipcp_down): fix comment * pppd/main.c: (reset_link_stats): reset print_link_stats to 1, set start_time even if get_ppp_stats fails. This is an attempt to fix the problem noted in the linux-ppp mailing list on mar-26-2024 and may-03-2024 under the subject "ppp-2.5.0 sometimes doesn't print stats on terminating on signal 2" The sent/recv log messages were being lost, especially with the persist option. This seems to be an oversight during reorg in commit ba7f7e0 "Header file reorganization and cleaning up the public API for pppd version 2.5.0 (#379)" around the repurposing of the link_stats_valid variable as link_stats_print. It also fixes a stray reference to the old variable in a comment. Signed-off-by: S Madhu --- pppd/ipcp.c | 2 +- pppd/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 1cf7f79..850e8cc 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -2026,7 +2026,7 @@ ipcp_down(fsm *f) sifvjcomp(f->unit, 0, 0, 0); print_link_stats(); /* _after_ running the notifiers and ip_down_hook(), - * because print_link_stats() sets link_stats_valid + * because print_link_stats() sets link_stats_print * to 0 (zero) */ /* diff --git a/pppd/main.c b/pppd/main.c index d62e603..b68917f 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -1334,9 +1334,9 @@ print_link_stats(void) void reset_link_stats(int u) { - if (!get_ppp_stats(u, &old_link_stats)) - return; + get_ppp_stats(u, &old_link_stats); ppp_get_time(&start_time); + link_stats_print = 1; } /* -- 2.39.5