move atexit code to xexit() and fix ftrunc order for mtime.
authorAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 00:42:31 +0000 (01:42 +0100)
committerAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 00:42:31 +0000 (01:42 +0100)
VERSION
tfc_error.c
tfcrypt.c

diff --git a/VERSION b/VERSION
index a2720097dccb441015beb4f75766b9908ad46f5a..425151f3a411f5e088d7753e7c8d016303b1b9d1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-39
+40
index 2108dc519a02a1822a305355c546ec39fe9526f8..3d95eba0cae6387a14800c4dfa7705ee52c1e447 100644 (file)
@@ -62,6 +62,14 @@ _ex:
 
 void xexit(int status)
 {
+       xclose(sfd);
+       if (do_ftrunc > TFC_NO_FTRUNC) {
+               if (do_ftrunc == TFC_FTRUNC_TAIL) ftrunc_dfd = total_processed_dst;
+               if (ftruncate(dfd, (off_t)ftrunc_dfd) == -1) xerror(YES, NO, YES, "ftruncate(%d)", dfd);
+       }
+       if (do_preserve_time) fcopy_matime(dfd, &s_stat);
+       xclose(dfd);
+
        memset(srcblk, 0, sizeof(srcblk));
        memset(dstblk, 0, sizeof(dstblk));
 
index 6ac7bdceb4da6879c98df6f6483e4cf4d3026559..15f23e2ea3159a71410c03b43c8abd85ad6cf1fa 100644 (file)
--- a/tfcrypt.c
+++ b/tfcrypt.c
@@ -1374,14 +1374,6 @@ _macwagain:              lio = xwrite(dfd, pblk, lrem);
 
        if (verbose || status_timer || do_stop == YES) print_crypt_status(0);
 
-       if (do_preserve_time) fcopy_matime(dfd, &s_stat);
-       xclose(sfd);
-       if (do_ftrunc > TFC_NO_FTRUNC) {
-               if (do_ftrunc == TFC_FTRUNC_TAIL) ftrunc_dfd = total_processed_dst;
-               if (ftruncate(dfd, (off_t)ftrunc_dfd) == -1) xerror(YES, NO, YES, "ftruncate(%d)", dfd);
-       }
-       xclose(dfd);
-
        xexit(exitcode);
        return -1;
 }