]> git.tuebingen.mpg.de Git - dss.git/blobdiff - dss.c
Don't create two snapshots in the same second.
[dss.git] / dss.c
diff --git a/dss.c b/dss.c
index 4202d08da8c0eeee0a567da6db239a5865beed6b..354bdb847095d0dd2b6a2346b9bdceaae7977d0d 100644 (file)
--- a/dss.c
+++ b/dss.c
 #include "gcc-compat.h"
 #include "cmdline.h"
 #include "log.h"
-#include "string.h"
-#include "error.h"
-#include "fd.h"
+#include "str.h"
+#include "err.h"
+#include "file.h"
 #include "exec.h"
 #include "daemon.h"
-#include "signal.h"
+#include "sig.h"
 #include "df.h"
-#include "time.h"
+#include "tv.h"
 #include "snap.h"
 #include "ipc.h"
 
@@ -548,10 +548,17 @@ static int rename_incomplete_snapshot(int64_t start)
 {
        char *old_name;
        int ret;
+       int64_t now;
 
+       /*
+        * We don't want the dss_rename() below to fail with EEXIST because the
+        * last complete snapshot was created (and completed) in the same
+        * second as this one.
+        */
+       while ((now = get_current_time()) == start)
+               sleep(1);
        free(path_to_last_complete_snapshot);
-       ret = complete_name(start, get_current_time(),
-               &path_to_last_complete_snapshot);
+       ret = complete_name(start, now, &path_to_last_complete_snapshot);
        if (ret < 0)
                return ret;
        old_name = incomplete_name(start);