summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-02-09 09:26:58 -0500
committerGitHub <noreply@github.com>2017-02-09 09:26:58 -0500
commitb7671f356aee0ce21e6e006e7b4ee57bd8e00b3d (patch)
tree253490726e4fca72b9391e81dbf146b0e005cad2 /lib/vty.c
parentcf80f28161ec05430723d6fb7bc5928bdc21f825 (diff)
parent1520d0aca9acf42faf0433cbe8f66ef9cd97bd0e (diff)
Merge pull request #190 from opensourcerouting/config-write-sync-stable
[stable] lib: use fsync() for config writes, plug fd leak
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 9594d68ebd..a39fe9f41b 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2330,9 +2330,16 @@ vty_close (struct vty *vty)
/* Unset vector. */
vector_unset (vtyvec, vty->fd);
+ if (vty->wfd > 0 && vty->type == VTY_FILE)
+ fsync (vty->wfd);
+
/* Close socket. */
if (vty->fd > 0)
- close (vty->fd);
+ {
+ close (vty->fd);
+ if (vty->wfd > 0 && vty->wfd != vty->fd)
+ close (vty->wfd);
+ }
else
vty_stdio_reset ();