lib: move at_close call in vty_stdio to end

Since the at_close call for the stdio vty might exit() the process, move
it to the end of the function, after freeing all memory.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-01-26 22:09:37 +01:00
parent bff9c3e9d3
commit dd03f8cae1

View File

@ -2227,6 +2227,7 @@ void
vty_close (struct vty *vty)
{
int i;
bool was_stdio;
/* Cancel threads.*/
if (vty->t_read)
@ -2254,7 +2255,7 @@ vty_close (struct vty *vty)
if (vty->fd > 0)
close (vty->fd);
else
vty_stdio_reset ();
was_stdio = true;
if (vty->buf)
XFREE (MTYPE_VTY, vty->buf);
@ -2267,6 +2268,9 @@ vty_close (struct vty *vty)
/* OK free vty. */
XFREE (MTYPE_VTY, vty);
if (was_stdio)
vty_stdio_reset ();
}
/* When time out occur output message then close connection. */