Skip to content

Commit

Permalink
Merge pull request #14813 from idryzhov/vtysh-file-lock
Browse files Browse the repository at this point in the history
vtysh: clean vtysh_file_locked when exiting config node
  • Loading branch information
donaldsharp authored Nov 20, 2023
2 parents 9ec7aa9 + 40def43 commit 83cbdcc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ static int vtysh_end(void)
/* Nothing to do. */
break;
default:
vty->vtysh_file_locked = false;
vty->node = ENABLE_NODE;
break;
}
Expand Down Expand Up @@ -2396,14 +2397,18 @@ static int vtysh_exit(struct vty *vty)
vty->node = cnode->parent_node;

if (vty->node == CONFIG_NODE) {
bool locked = vty->vtysh_file_locked;

/* resync in case one of the daemons is somewhere else */
vtysh_execute("end");
/* NOTE: a rather expensive thing to do, can we avoid it? */

if (vty->vtysh_file_locked)
if (locked)
vtysh_execute("configure terminal file-lock");
else
vtysh_execute("configure terminal");
} else if (vty->node == ENABLE_NODE) {
vty->vtysh_file_locked = false;
}

return CMD_SUCCESS;
Expand Down

0 comments on commit 83cbdcc

Please sign in to comment.