[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 02/02: -fix close error handling
From: |
gnunet |
Subject: |
[gnunet] 02/02: -fix close error handling |
Date: |
Tue, 26 Nov 2024 19:19:49 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 46225cc04fdad63b575ac775f1421888f2d01b5c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Nov 26 19:19:43 2024 +0100
-fix close error handling
---
src/lib/util/disk.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/lib/util/disk.c b/src/lib/util/disk.c
index 558003a25..4202d021a 100644
--- a/src/lib/util/disk.c
+++ b/src/lib/util/disk.c
@@ -370,19 +370,33 @@ GNUNET_DISK_file_backup (const char *fil)
#if HAVE_RENAMEAT2
{
int fd;
+
do
{
- GNUNET_snprintf (target, slen, "%s.%u~", fil, num++);
- fd = open (target, O_CREAT | O_EXCL,
+ GNUNET_snprintf (target,
+ slen,
+ "%s.%u~",
+ fil,
+ num++);
+ fd = open (target,
+ O_CREAT | O_EXCL,
translate_unix_perms (GNUNET_DISK_PERM_USER_WRITE));
} while (-1 == fd);
- if (0 != renameat2 (AT_FDCWD, fil, AT_FDCWD, target, RENAME_EXCHANGE))
+ if (0 != renameat2 (AT_FDCWD,
+ fil,
+ AT_FDCWD,
+ target,
+ RENAME_EXCHANGE))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "renameat2", fil);
- close (fd);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "renameat2",
+ fil);
+ GNUNET_break (0 ==
+ close (fd));
return NULL;
}
- close (fd);
+ GNUNET_break (0 ==
+ close (fd));
}
#else
do
@@ -672,7 +686,8 @@ GNUNET_DISK_fn_read (const char *fn,
return GNUNET_SYSERR;
ret = GNUNET_DISK_file_read (fh, result, len);
eno = errno;
- GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_DISK_file_close (fh));
errno = eno;
return ret;
}
@@ -1154,13 +1169,17 @@ GNUNET_DISK_file_copy (const char *src,
pos += len;
}
GNUNET_free (buf);
- GNUNET_DISK_file_close (in);
- GNUNET_DISK_file_close (out);
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_DISK_file_close (in));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_DISK_file_close (out));
return GNUNET_OK;
FAIL:
GNUNET_free (buf);
- GNUNET_DISK_file_close (in);
- GNUNET_DISK_file_close (out);
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_DISK_file_close (in));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_DISK_file_close (out));
return GNUNET_SYSERR;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.