From ed553c3df8511a89ec70d78f52783d10bf8252bd Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 2 Apr 2020 14:03:17 +0200 Subject: [PATCH] lib/vty: don't print to closed vty vty_config_exit() may be called when the vty is already mostly gone, i.e. when we lost a connection or pipe. Drop the warnings in that case, they won't make it anywhere. Signed-off-by: David Lamparter --- lib/vty.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vty.c b/lib/vty.c index 10851fc595b8..e75e49c4081d 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2615,8 +2615,9 @@ void vty_config_exit(struct vty *vty) node = cnode->parent_node; } if (node != CONFIG_NODE) { - vty_out(vty, - "WARNING: vty_config_exit() from outside CONFIG_NODE!\n"); + if (vty->status != VTY_CLOSE) + vty_out(vty, + "WARNING: vty_config_exit() from outside CONFIG_NODE!\n"); return; } @@ -2628,8 +2629,9 @@ void vty_config_exit(struct vty *vty) /* Check if there's a pending confirmed commit. */ if (vty->t_confirmed_commit_timeout) { - vty_out(vty, - "WARNING: exiting with a pending confirmed commit. Rolling back to previous configuration.\n\n"); + if (vty->status != VTY_CLOSE) + vty_out(vty, + "WARNING: exiting with a pending confirmed commit. Rolling back to previous configuration.\n\n"); nb_cli_confirmed_commit_rollback(vty); nb_cli_confirmed_commit_clean(vty); }