[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r38117 - libmicrohttpd/src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r38117 - libmicrohttpd/src/microhttpd |
Date: |
Tue, 11 Oct 2016 17:21:20 +0200 |
Author: Karlson2k
Date: 2016-10-11 17:21:20 +0200 (Tue, 11 Oct 2016)
New Revision: 38117
Modified:
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/microhttpd/mhd_itc.h
Log:
Renamed 'MHD_pipe_close' -> 'MHD_itc_destroy_'
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2016-10-11 15:21:17 UTC (rev
38116)
+++ libmicrohttpd/src/microhttpd/daemon.c 2016-10-11 15:21:20 UTC (rev
38117)
@@ -4473,7 +4473,7 @@
_("Failed to make read side of inter-thread control channel
non-blocking: %s\n"),
MHD_itc_last_strerror_ ());
#endif
- MHD_pipe_close_ (daemon->itc);
+ MHD_itc_destroy_chk_ (daemon->itc);
free (daemon);
return NULL;
}
@@ -4487,7 +4487,7 @@
MHD_DLOG (daemon,
_("file descriptor for control pipe exceeds maximum value\n"));
#endif
- MHD_pipe_close_ (daemon->itc);
+ MHD_itc_destroy_chk_ (daemon->itc);
free (daemon);
return NULL;
}
@@ -5005,7 +5005,7 @@
MHD_DLOG (daemon,
_("File descriptor for worker control pipe exceeds
maximum value\n"));
#endif
- MHD_pipe_close_ (d->itc);
+ MHD_itc_destroy_chk_ (d->itc);
goto thread_failed;
}
@@ -5112,7 +5112,7 @@
gnutls_priority_deinit (daemon->priority_cache);
#endif
if (! MHD_INVALID_PIPE_(daemon->itc))
- MHD_pipe_close_ (daemon->itc);
+ MHD_itc_destroy_chk_ (daemon->itc);
free (daemon);
return NULL;
}
@@ -5339,7 +5339,7 @@
{
if (! MHD_INVALID_PIPE_ (daemon->worker_pool[i].itc) )
{
- MHD_pipe_close_ (daemon->worker_pool[i].itc);
+ MHD_itc_destroy_chk_ (daemon->worker_pool[i].itc);
}
}
}
@@ -5395,7 +5395,7 @@
MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex);
if (! MHD_INVALID_PIPE_(daemon->itc))
- MHD_pipe_close_ (daemon->itc);
+ MHD_itc_destroy_chk_ (daemon->itc);
free (daemon);
}
Modified: libmicrohttpd/src/microhttpd/mhd_itc.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:21:17 UTC (rev
38116)
+++ libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:21:20 UTC (rev
38117)
@@ -36,6 +36,15 @@
#include <fcntl.h>
+#ifndef MHD_PANIC
+# include <stdio.h>
+# include <stdlib.h>
+/* Simple implementation of MHD_PANIC, to be used outside lib */
+# define MHD_PANIC(msg) do { fprintf (stderr, \
+ "Abnormal termination at %d line in file %s: %s\n", \
+ (int)__LINE__, __FILE__, msg); abort();} while(0)
+#endif /* ! MHD_PANIC */
+
#if defined(_MHD_ITC_EVENTFD)
/* **************** Optimized GNU/Linux ITC implementation by eventfd
********** */
@@ -99,13 +108,11 @@
(void)__r; } while(0)
/**
- * Close any FDs of the pipe (non-W32)
+ * Destroy previously initialised ITC
+ * @param itc the itc to destroy
+ * @return non-zero if succeeded, zero otherwise
*/
-#define MHD_pipe_close_(pip) do { \
- if ( (0 != close (pip)) && \
- (EBADF == errno) ) \
- MHD_PANIC (_("close failed")); \
- } while (0)
+#define MHD_itc_destroy_(itc) ((0 != close (itc)) || (EBADF != errno))
/**
* Check if we have an uninitialized pipe
@@ -188,16 +195,14 @@
{} } while(0)
/**
- * Close any FDs of the pipe (non-W32)
+ * Destroy previously initialised ITC
+ * @param itc the itc to destroy
+ * @return non-zero if succeeded, zero otherwise
*/
-#define MHD_pipe_close_(pip) do { \
- if ( (0 != close ((pip).fd[0])) && \
- (EBADF == errno) ) \
- MHD_PANIC (_("close failed")); \
- if ( (0 != close ((pip).fd[1])) && \
- (EBADF == errno) ) \
- MHD_PANIC (_("close failed")); \
- } while (0)
+#define MHD_itc_destroy_(itc) \
+ ( (0 == close ((itc).fd[0])) ? \
+ (0 == close ((itc).fd[1])) : \
+ ((close ((itc).fd[1])), 0) )
/**
* Check if we have an uninitialized pipe
@@ -276,12 +281,14 @@
{} } while(0)
/**
- * Close emulated pipe FDs
+ * Destroy previously initialised ITC
+ * @param itc the itc to destroy
+ * @return non-zero if succeeded, zero otherwise
*/
-#define MHD_pipe_close_(pip) do { \
- MHD_socket_close_chk_ ((pip).sk[0]); \
- MHD_socket_close_chk_ ((pip).sk[1]); \
-} while (0)
+#define MHD_itc_destroy_(itc) \
+ ( MHD_socket_close_((itc).sk[0]) ? \
+ MHD_socket_close_((itc).sk[1]) : \
+ ((void)MHD_socket_close_((itc).sk[1]), 0) )
/**
* Check for uninitialized pipe @a pip
@@ -300,4 +307,14 @@
#endif /* _MHD_ITC_SOCKETPAIR */
+/**
+ * Destroy previously initialised ITC and abort execution
+ * if error is detected.
+ * @param itc the itc to destroy
+ */
+#define MHD_itc_destroy_chk_(itc) do { \
+ if (!MHD_itc_destroy_(itc)) \
+ MHD_PANIC(_("Failed to destroy ITC.\n")); \
+ } while(0)
+
#endif /* MHD_ITC_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r38117 - libmicrohttpd/src/microhttpd,
gnunet <=