]> 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 7620cfee1733d55ef99baaf956e11089db9b40d6..354bdb847095d0dd2b6a2346b9bdceaae7977d0d 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -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);