]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: Call fflush+fsync before calling fclose() when saving the config
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 19 Apr 2022 11:01:13 +0000 (14:01 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 19 Apr 2022 11:01:13 +0000 (14:01 +0300)
A safety check we flushed the data to the storage.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
vtysh/vtysh.c

index 0b85b2ea496f7666c21cc71638b58af3832e8866..74886254bdb936e22e78e089eeea48f5b7e9f962 100644 (file)
@@ -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);