summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2022-04-19 18:37:18 -0400
committerGitHub <noreply@github.com>2022-04-19 18:37:18 -0400
commit4069e53960cecc8b59c7e5f8026cbe992aedb31d (patch)
treea4e816390510920e1b8830d65c15b1942e6aeb89
parent945f6ce22c19464c31942c883eb6533903c141cd (diff)
parent789c5919cf355afdac9ed24e468c8009df0f163b (diff)
Merge pull request #11048 from opensourcerouting/fix/fsync_before_fclose
vtysh: Call fflush+fsync before calling fclose() when saving the config
-rw-r--r--vtysh/vtysh.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 0b85b2ea49..74886254bd 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3361,6 +3361,18 @@ int vtysh_write_config_integrated(void)
err++;
}
+ if (fflush(fp) != 0) {
+ printf("%% Warning: fflush() failed on %s: %s\n", frr_config,
+ safe_strerror(errno));
+ err++;
+ }
+
+ if (fsync(fd) < 0) {
+ printf("%% Warning: fsync() failed on %s: %s\n", frr_config,
+ safe_strerror(errno));
+ err++;
+ }
+
fclose(fp);
printf("Integrated configuration saved to %s\n", frr_config);