gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 01/02: fix close() checks


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 01/02: fix close() checks
Date: Mon, 08 Apr 2019 15:12:49 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libmicrohttpd.

commit 83a86be948420f7bd902ceee9d661fc208eec1cd
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Apr 8 15:12:20 2019 +0200

    fix close() checks
---
 ChangeLog                 | 4 ++++
 src/lib/internal.h        | 6 +++---
 src/lib/mhd_itc.h         | 6 ++++--
 src/microhttpd/internal.h | 6 +++---
 src/microhttpd/mhd_itc.h  | 6 ++++--
 5 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aaf17bb2..dee553f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon 08 Apr 2019 03:06:05 PM CEST
+       Fix close() checks as suggested by MK on the mailinglist
+        (#3926). -MK/CG
+
 Tue Jan  8 02:57:21 BRT 2019
        Added minimal example for how to compress HTTP response. -SC
 
diff --git a/src/lib/internal.h b/src/lib/internal.h
index c6d7bec6..bd3bd1c6 100644
--- a/src/lib/internal.h
+++ b/src/lib/internal.h
@@ -92,9 +92,9 @@ MHD_DLOG (const struct MHD_Daemon *daemon,
  * Close FD and abort execution if error is detected.
  * @param fd the FD to close
  */
-#define MHD_fd_close_chk_(fd) do {             \
-    if (0 == close ((fd)) && (EBADF == errno)) \
-      MHD_PANIC(_("Failed to close FD.\n"));   \
+#define MHD_fd_close_chk_(fd) do {                      \
+    if ( (0 != close ((fd)) && (EBADF == errno)) )     \
+      MHD_PANIC(_("Failed to close FD.\n"));            \
   } while(0)
 
 /**
diff --git a/src/lib/mhd_itc.h b/src/lib/mhd_itc.h
index 7bfccf30..01331f13 100644
--- a/src/lib/mhd_itc.h
+++ b/src/lib/mhd_itc.h
@@ -108,11 +108,13 @@ static const uint64_t _MHD_itc_wr_data = 1;
        (void)__r; } while(0)
 
 /**
- * Destroy previously initialised ITC
+ * Destroy previously initialised ITC.  Note that close()
+ * on some platforms returns odd errors, so we ONLY fail
+ * if the errno is EBADF.
  * @param itc the itc to destroy
  * @return non-zero if succeeded, zero otherwise
  */
-#define MHD_itc_destroy_(itc) ((0 != close ((itc).fd)) || (EBADF != errno))
+#define MHD_itc_destroy_(itc) ((0 == close ((itc).fd)) || (EBADF != errno))
 
 /**
  * Check whether ITC has valid value.
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 0ce0b0c8..d09de610 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -77,9 +77,9 @@
  * Close FD and abort execution if error is detected.
  * @param fd the FD to close
  */
-#define MHD_fd_close_chk_(fd) do {             \
-    if (0 == close ((fd)) && (EBADF == errno)) \
-      MHD_PANIC(_("Failed to close FD.\n"));   \
+#define MHD_fd_close_chk_(fd) do {                      \
+    if ( (0 != close ((fd)) && (EBADF == errno)) )     \
+      MHD_PANIC(_("Failed to close FD.\n"));            \
   } while(0)
 
 /**
diff --git a/src/microhttpd/mhd_itc.h b/src/microhttpd/mhd_itc.h
index 7bfccf30..01331f13 100644
--- a/src/microhttpd/mhd_itc.h
+++ b/src/microhttpd/mhd_itc.h
@@ -108,11 +108,13 @@ static const uint64_t _MHD_itc_wr_data = 1;
        (void)__r; } while(0)
 
 /**
- * Destroy previously initialised ITC
+ * Destroy previously initialised ITC.  Note that close()
+ * on some platforms returns odd errors, so we ONLY fail
+ * if the errno is EBADF.
  * @param itc the itc to destroy
  * @return non-zero if succeeded, zero otherwise
  */
-#define MHD_itc_destroy_(itc) ((0 != close ((itc).fd)) || (EBADF != errno))
+#define MHD_itc_destroy_(itc) ((0 == close ((itc).fd)) || (EBADF != errno))
 
 /**
  * Check whether ITC has valid value.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]