From 093131279777dd0af9fef493abfb7bd6dc9c1c79 Mon Sep 17 00:00:00 2001 From: Andrey Rys Date: Sun, 28 Nov 2021 01:42:31 +0100 Subject: [PATCH] move atexit code to xexit() and fix ftrunc order for mtime. --- VERSION | 2 +- tfc_error.c | 8 ++++++++ tfcrypt.c | 8 -------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index a272009..425151f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -39 +40 diff --git a/tfc_error.c b/tfc_error.c index 2108dc5..3d95eba 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -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)); diff --git a/tfcrypt.c b/tfcrypt.c index 6ac7bdc..15f23e2 100644 --- 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; } -- 2.31.1