summaryrefslogtreecommitdiffstats
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-02-08 16:14:10 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-02-09 14:25:55 +0100
commit1520d0aca9acf42faf0433cbe8f66ef9cd97bd0e (patch)
tree253490726e4fca72b9391e81dbf146b0e005cad2 /lib/vty.c
parentMerge pull request #179 from donaldsharp/more_quagga_fixups (diff)
downloadfrr-1520d0aca9acf42faf0433cbe8f66ef9cd97bd0e.tar.xz
frr-1520d0aca9acf42faf0433cbe8f66ef9cd97bd0e.zip
lib: use fsync() for config writes, plug fd leak
sync() has a HUGE impact on systems that perform actual I/O, i.e. real servers... Also, we were leaking a fd on each config write ever since c5e69a0 "lib/vty: add separate output fd support to VTYs" (by myself :( ...) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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 9594d68eb..a39fe9f41 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 ();