From 91fd1b8d9cf692c8f88afc5900c2d1ad16a871e8 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 28 Sep 2017 14:01:05 -0400 Subject: [PATCH] vtysh: more multi-instance fixing Preexisting code to detect commands targeted at wrong instance didn't work because a command applied to a disconnected vtysh_client counted as a successful run overriding wrong instance error message Signed-off-by: Quentin Young --- vtysh/vtysh.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 05d0ac5612..73440461ec 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -226,7 +226,8 @@ static int vtysh_client_run_all(struct vtysh_client *head_client, wrong_instance++; continue; } - correct_instance++; + if (client->fd > 0) + correct_instance++; if (rc != CMD_SUCCESS) { if (!continue_on_err) return rc; @@ -433,11 +434,12 @@ static int vtysh_execute_func(const char *line, int pager) vc = vc->next) any_inst = any_inst || (vc->fd > 0); - if (!any_inst) + if (!any_inst) { fprintf(stderr, "%s is not running\n", vtysh_client[i].name); - continue; + continue; + } } cmd_stat = vtysh_client_execute( &vtysh_client[i], line, fp); -- 2.39.5