summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-02-09 09:52:58 -0500
committerGitHub <noreply@github.com>2017-02-09 09:52:58 -0500
commitb9aa3abbbebb7db75f7209938074aa0cac6d377d (patch)
tree77461b93bf06d698f91fc98d5ba4f89979dc06f9 /lib/vty.c
parent9c3a235e8a8bbfc0c4465bb26bf36981bd387899 (diff)
parent056cfe496e84eed72c4d2226a7a405e5263cdc7a (diff)
Merge pull request #189 from opensourcerouting/config-write-sync
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 2660ca3251..0568351989 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2254,9 +2254,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
was_stdio = true;