aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-10-11 04:13:13 +0200
committerMattias Andrée <maandree@operamail.com>2015-10-11 04:13:13 +0200
commit0a85228ff762b77de2d47119d1379e7ca6f48eb8 (patch)
treee2e936730368062cbafb42e6be6e8b57d5b192ce /src/libmdsserver
parentwhoops (diff)
downloadmds-0a85228ff762b77de2d47119d1379e7ca6f48eb8.tar.gz
mds-0a85228ff762b77de2d47119d1379e7ca6f48eb8.tar.bz2
mds-0a85228ff762b77de2d47119d1379e7ca6f48eb8.tar.xz
Whilst POSIX leaves it explicitly unspecify whether close(2) closes the fildes on interruption, Linux (and possibly some other kernels) specify that it does close.
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/macros.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h
index c42ef21..71d26f1 100644
--- a/src/libmdsserver/macros.h
+++ b/src/libmdsserver/macros.h
@@ -396,12 +396,16 @@
*
* @param fd:int The file descriptor
*/
-#ifdef MDS_LIBMDSSERVER_MACROS_DEFINED_TEMP_FAILURE_RETRY
-# define xclose(fd) \
+#if 1 /* For kernels that ensure that close(2) always closes valid file descriptors. */
+# define xclose(fd) close(fd)
+#else /* For kernels that ensure that close(2) never closes valid file descriptors on interruption. */
+# ifdef MDS_LIBMDSSERVER_MACROS_DEFINED_TEMP_FAILURE_RETRY
+# define xclose(fd) \
TEMP_FAILURE_RETRY(close(fd))
-#else
-# define xclose(fd) \
+# else
+# define xclose(fd) \
(TEMP_FAILURE_RETRY(close(fd)) < 0 ? 0 : (errno = 0))
+# endif
#endif
@@ -411,12 +415,16 @@
*
* @param f:FILE* The stream
*/
-#ifdef MDS_LIBMDSSERVER_MACROS_DEFINED_TEMP_FAILURE_RETRY
-# define xfclose(f) \
+#if 1 /* For kernels that ensure that close(2) always closes valid file descriptors. */
+# define xfclose(f) fclose(f)
+#else /* For kernels that ensure that close(2) never closes valid file descriptors on interruption. */
+# ifdef MDS_LIBMDSSERVER_MACROS_DEFINED_TEMP_FAILURE_RETRY
+# define xfclose(f) \
TEMP_FAILURE_RETRY(fclose(f))
-#else
-# define xfclose(f) \
+# else
+# define xfclose(f) \
(TEMP_FAILURE_RETRY(fclose(f)) < 0 ? 0 : (errno = 0))
+# endif
#endif