[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r38108 - libmicrohttpd/src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r38108 - libmicrohttpd/src/microhttpd |
Date: |
Tue, 11 Oct 2016 17:20:53 +0200 |
Author: Karlson2k
Date: 2016-10-11 17:20:53 +0200 (Tue, 11 Oct 2016)
New Revision: 38108
Modified:
libmicrohttpd/src/microhttpd/internal.h
libmicrohttpd/src/microhttpd/mhd_itc.c
libmicrohttpd/src/microhttpd/mhd_itc.h
Log:
Renamed "pipe" to "itc" as it actually more some kind of channel, not always
pipe.
Used typedef for "itc" type.
Modified: libmicrohttpd/src/microhttpd/internal.h
===================================================================
--- libmicrohttpd/src/microhttpd/internal.h 2016-10-11 15:20:50 UTC (rev
38107)
+++ libmicrohttpd/src/microhttpd/internal.h 2016-10-11 15:20:53 UTC (rev
38108)
@@ -1352,13 +1352,9 @@
#endif
/**
- * Pipe we use to signal shutdown, unless
- * 'HAVE_LISTEN_SHUTDOWN' is defined AND we have a listen
- * socket (which we can then 'shutdown' to stop listening).
- * MHD can be build with usage of socketpair instead of
- * pipe (forced on W32).
+ * Inter-thread communication channel.
*/
- struct MHD_Pipe wpipe;
+ MHD_itc_ wpipe;
/**
* Are we shutting down?
Modified: libmicrohttpd/src/microhttpd/mhd_itc.c
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_itc.c 2016-10-11 15:20:50 UTC (rev
38107)
+++ libmicrohttpd/src/microhttpd/mhd_itc.c 2016-10-11 15:20:53 UTC (rev
38108)
@@ -36,13 +36,13 @@
#ifdef _MHD_ITC_EVENTFD
int
-MHD_pipe_write_ (struct MHD_Pipe pip,
+MHD_pipe_write_ (MHD_itc_ pip,
const void *ptr,
size_t sz)
{
uint64_t val = 1;
if (sizeof (val) !=
- write (pip.event_fd,
+ write (pip,
&val,
sizeof (val)))
MHD_PANIC (_("Failed to write to eventfd\n"));
@@ -62,7 +62,7 @@
* @return non-zero if succeeded, zero otherwise
*/
int
-MHD_itc_nonblocking_ (struct MHD_Pipe pip)
+MHD_itc_nonblocking_ (MHD_itc_ itc)
{
unsigned int i;
@@ -70,7 +70,7 @@
{
int flags;
- flags = fcntl (pip.fd[i],
+ flags = fcntl (itc.fd[i],
F_GETFL);
if (-1 == flags)
return 0;
Modified: libmicrohttpd/src/microhttpd/mhd_itc.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:20:50 UTC (rev
38107)
+++ libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:20:53 UTC (rev
38108)
@@ -20,7 +20,7 @@
/**
* @file microhttpd/mhd_itc.h
- * @brief Header for platform-independent inter-thread signaling via pipes
+ * @brief Header for platform-independent inter-thread communication
* @author Karlson2k (Evgeny Grin)
* @author Christian Grothoff
*
@@ -47,20 +47,17 @@
#if defined(_MHD_ITC_EVENTFD)
#include <sys/eventfd.h>
-/* **************** Optimized eventfd PIPE implementation ********** */
+/* **************** Optimized GNU/Linux ITC implementation by eventfd
********** */
/**
- * Data type for a MHD pipe.
+ * Data type for a MHD ITC.
*/
-struct MHD_Pipe
-{
- int event_fd;
-};
+typedef int MHD_itc_;
/**
* create pipe
*/
-#define MHD_pipe_(pip) ((-1 == (pip.event_fd = eventfd (0, EFD_CLOEXEC |
EFD_NONBLOCK))) ? 0 : !0)
+#define MHD_pipe_(itc) ((-1 == (itc = eventfd (0, EFD_CLOEXEC |
EFD_NONBLOCK))) ? 0 : !0)
/***
* Get description string of last errno for pipe operations.
@@ -71,13 +68,13 @@
* write data to real pipe
*/
int
-MHD_pipe_write_ (struct MHD_Pipe pip,
+MHD_pipe_write_ (MHD_itc_ pip,
const void *ptr,
size_t sz);
-#define MHD_pipe_get_read_fd_(pip) (pip.event_fd)
+#define MHD_pipe_get_read_fd_(pip) (pip)
-#define MHD_pipe_get_write_fd_(pip) (pip.event_fd)
+#define MHD_pipe_get_write_fd_(pip) (pip)
/**
* drain data from real pipe
@@ -84,7 +81,7 @@
*/
#define MHD_pipe_drain_(pip) do { \
uint64_t tmp; \
- read (pip.event_fd, &tmp, sizeof (tmp)); \
+ read (pip, &tmp, sizeof (tmp)); \
} while (0)
/**
@@ -91,7 +88,7 @@
* Close any FDs of the pipe (non-W32)
*/
#define MHD_pipe_close_(pip) do { \
- if ( (0 != close (pip.event_fd)) && \
+ if ( (0 != close (pip)) && \
(EBADF == errno) ) \
MHD_PANIC (_("close failed")); \
} while (0)
@@ -99,13 +96,13 @@
/**
* Check if we have an uninitialized pipe
*/
-#define MHD_INVALID_PIPE_(pip) (-1 == pip.event_fd)
+#define MHD_INVALID_PIPE_(pip) (-1 == pip)
/**
* Setup uninitialized @a pip data structure.
*/
#define MHD_make_invalid_pipe_(pip) do { \
- pip.event_fd = -1; \
+ pip = -1; \
} while (0)
@@ -121,7 +118,7 @@
#elif defined(_MHD_ITC_PIPE)
-/* **************** STANDARD UNIX PIPE implementation ********** */
+/* **************** Standard UNIX ITC implementation by pipe ********** */
# ifdef HAVE_STRING_H
# include <string.h> /* for strerror() */
@@ -128,17 +125,18 @@
# endif
/**
- * Data type for a MHD pipe.
+ * Data type for a MHD ITC.
*/
-struct MHD_Pipe
+struct MHD_Itc
{
int fd[2];
};
+typedef struct MHD_Itc MHD_itc_;
/**
* create pipe
*/
-#define MHD_pipe_(pip) (!pipe((pip.fd)))
+#define MHD_pipe_(pip) (!pipe((pip).fd))
/***
* Get description string of last errno for pipe operations.
@@ -148,12 +146,12 @@
/**
* write data to real pipe
*/
-#define MHD_pipe_write_(pip, ptr, sz) write((pip.fd[1]), (const void*)(ptr),
(sz))
+#define MHD_pipe_write_(pip, ptr, sz) write((pip).fd[1], (const void*)(ptr),
(sz))
-#define MHD_pipe_get_read_fd_(pip) (pip.fd[0])
+#define MHD_pipe_get_read_fd_(pip) ((pip).fd[0])
-#define MHD_pipe_get_write_fd_(pip) (pip.fd[1])
+#define MHD_pipe_get_write_fd_(pip) ((pip).fd[1])
/**
* drain data from real pipe
@@ -160,7 +158,7 @@
*/
#define MHD_pipe_drain_(pip) do { \
long tmp; \
- while (0 < read((pip.fd[0]), (void*)&tmp, sizeof (tmp))) ; \
+ while (0 < read((pip).fd[0], (void*)&tmp, sizeof (tmp))) ; \
} while (0)
/**
@@ -167,10 +165,10 @@
* Close any FDs of the pipe (non-W32)
*/
#define MHD_pipe_close_(pip) do { \
- if ( (0 != close (pip.fd[0])) && \
+ if ( (0 != close ((pip).fd[0])) && \
(EBADF == errno) ) \
MHD_PANIC (_("close failed")); \
- if ( (0 != close (pip.fd[1])) && \
+ if ( (0 != close ((pip).fd[1])) && \
(EBADF == errno) ) \
MHD_PANIC (_("close failed")); \
} while (0)
@@ -178,13 +176,13 @@
/**
* Check if we have an uninitialized pipe
*/
-#define MHD_INVALID_PIPE_(pip) (-1 == pip.fd[0])
+#define MHD_INVALID_PIPE_(pip) (-1 == (pip).fd[0])
/**
* Setup uninitialized @a pip data structure.
*/
#define MHD_make_invalid_pipe_(pip) do { \
- pip.fd[0] = pip.fd[1] = -1; \
+ (pip).fd[0] = (pip).fd[1] = -1; \
} while (0)
/**
@@ -194,14 +192,12 @@
* @return non-zero if succeeded, zero otherwise
*/
int
-MHD_itc_nonblocking_ (struct MHD_Pipe fd);
+MHD_itc_nonblocking_ (MHD_itc_ itc);
-/* **************** END OF STANDARD UNIX PIPE implementation ********** */
-
#elif defined(_MHD_ITC_SOCKETPAIR)
-/* **************** PIPE EMULATION by socket pairs ********** */
+/* **************** ITC implementation by socket pair ********** */
#include "mhd_sockets.h"
@@ -208,12 +204,12 @@
/**
* Data type for a MHD pipe.
*/
-struct MHD_Pipe
+struct MHD_Itc
{
MHD_socket fd[2];
};
+typedef struct MHD_Itc MHD_itc_;
-
/**
* Create two connected sockets to emulate a pipe.
*/
@@ -262,8 +258,6 @@
#define MHD_itc_nonblocking_(pip) (MHD_socket_nonblocking_((pip.fd[0])) &&
MHD_socket_nonblocking_((pip.fd[1])))
-/* **************** END OF PIPE EMULATION by socket pairs ********** */
-
#endif /* _MHD_ITC_SOCKETPAIR */
#endif /* MHD_ITC_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r38108 - libmicrohttpd/src/microhttpd,
gnunet <=