gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. 07


From: gitolite
Subject: [GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. 0724b181bd61b544b7e27b399711c1fc871e25ea
Date: Mon, 17 Oct 2016 16:23:08 +0200 (CEST)

The branch, master has been updated
       via  0724b181bd61b544b7e27b399711c1fc871e25ea (commit)
       via  fa6909d5e18a70a8aa01da488634c3d1b643141d (commit)
       via  554018347f6bf94c9643e6d7edc3f5d0f0ad1d9e (commit)
      from  d9312296fda11c1880d8f28c4396af9eab633ead (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0724b181bd61b544b7e27b399711c1fc871e25ea
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Oct 17 17:19:29 2016 +0300

    Simplify portability by using MHD_recv_() wrapper macro

commit fa6909d5e18a70a8aa01da488634c3d1b643141d
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Oct 17 16:57:22 2016 +0300

    Simplify portability by using MHD_send_() wrapper macro

commit 554018347f6bf94c9643e6d7edc3f5d0f0ad1d9e
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Oct 17 17:11:08 2016 +0300

    Fixed incorrect recv() flag

-----------------------------------------------------------------------

Summary of changes:
 src/microhttpd/connection.c  |  7 +++---
 src/microhttpd/daemon.c      | 52 ++++++++++++++++----------------------------
 src/microhttpd/mhd_itc.h     |  4 ++--
 src/microhttpd/mhd_sockets.h | 47 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 39 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 7287b7e..3a121b9 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -269,10 +269,9 @@ socket_start_no_buffering_flush (struct MHD_Connection 
*connection)
   /* Force flush data with zero send otherwise Darwin and some BSD systems
      will add 5 seconds delay. Not required with TCP_CORK as switching off
      TCP_CORK always flushes socket buffer. */
-  res &= (0 <= send (connection->socket_fd,
-                     (const void *) &dummy,
-                     0,
-                     0))
+  res &= (0 <= MHD_send_ (connection->socket_fd,
+                          &dummy,
+                          0))
     ? MHD_YES : MHD_NO;
 #endif /* TCP_NOPUSH && !TCP_CORK*/
   return res;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index d3fc81b..2f52df0 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -86,12 +86,6 @@
  */
 #define DEBUG_CONNECT MHD_NO
 
-#ifndef LINUX
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-#endif
-
 
 /**
  * Default implementation of the panic function,
@@ -1038,11 +1032,11 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
   if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) &&
        (urh->in_buffer_off > 0) )
     {
-      size_t res;
+      ssize_t res;
 
-      res = write (urh->mhd.socket,
-                   urh->in_buffer,
-                   urh->in_buffer_off);
+      res = MHD_send_ (urh->mhd.socket,
+                       urh->in_buffer,
+                       urh->in_buffer_off);
       if (-1 == res)
         {
           int err = MHD_socket_get_error_ ();
@@ -1078,11 +1072,11 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
   if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) &&
        (urh->out_buffer_off < urh->out_buffer_size) )
     {
-      size_t res;
+      ssize_t res;
 
-      res = read (urh->mhd.socket,
-                  &urh->out_buffer[urh->out_buffer_off],
-                  urh->out_buffer_size - urh->out_buffer_off);
+      res = MHD_recv_ (urh->mhd.socket,
+                       &urh->out_buffer[urh->out_buffer_off],
+                       urh->out_buffer_size - urh->out_buffer_off);
       if (-1 == res)
         {
           /* FIXME: differenciate by errno? */
@@ -1604,10 +1598,9 @@ recv_param_adapter (struct MHD_Connection *connection,
     i = INT_MAX; /* return value limit */
 #endif /* MHD_WINSOCK_SOCKETS */
 
-  ret = (ssize_t) recv (connection->socket_fd,
-                        other,
-                        (MHD_SCKT_SEND_SIZE_) i,
-                        MSG_NOSIGNAL);
+  ret = MHD_recv_ (connection->socket_fd,
+                   other,
+                   i);
 #ifdef EPOLL_SUPPORT
   if ( (0 > ret) &&
        (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) )
@@ -1645,19 +1638,13 @@ send_param_adapter (struct MHD_Connection *connection,
       MHD_socket_set_error_ (MHD_SCKT_ENOTCONN_);
       return -1;
     }
-#ifdef MHD_POSIX_SOCKETS
-  if (i > SSIZE_MAX)
-    i = SSIZE_MAX; /* return value limit */
-#else  /* MHD_WINSOCK_SOCKETS */
-  if (i > INT_MAX)
-    i = INT_MAX; /* return value limit */
-#endif /* MHD_WINSOCK_SOCKETS */
+  if (i > MHD_SCKT_SEND_MAX_SIZE_)
+    i = MHD_SCKT_SEND_MAX_SIZE_; /* return value limit */
 
   if (0 != (connection->daemon->options & MHD_USE_TLS))
-    return (ssize_t) send (connection->socket_fd,
-                           other,
-                           (MHD_SCKT_SEND_SIZE_) i,
-                           MSG_NOSIGNAL);
+    return MHD_send_ (connection->socket_fd,
+                      other,
+                      i);
 #if LINUX
   if ( (connection->write_buffer_append_offset ==
        connection->write_buffer_send_offset) &&
@@ -1716,10 +1703,9 @@ send_param_adapter (struct MHD_Connection *connection,
         http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html 
*/
     }
 #endif
-  ret = (ssize_t) send (connection->socket_fd,
-                        other,
-                        (MHD_SCKT_SEND_SIZE_) i,
-                        MSG_NOSIGNAL);
+  ret = MHD_send_ (connection->socket_fd,
+                   other,
+                   i);
   err = MHD_socket_get_error_();
 #ifdef EPOLL_SUPPORT
   if ( (0 > ret) &&
diff --git a/src/microhttpd/mhd_itc.h b/src/microhttpd/mhd_itc.h
index df92b53..7bfccf3 100644
--- a/src/microhttpd/mhd_itc.h
+++ b/src/microhttpd/mhd_itc.h
@@ -274,8 +274,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
  * @param str one-symbol string, useful only for strace debug
  * @return non-zero if succeeded, zero otherwise
  */
-#define MHD_itc_activate_(itc, str) \
-  ((send((itc).sk[1], (const char*)(str), 1, 0) > 0) || \
+#define MHD_itc_activate_(itc, str)          \
+  ((MHD_send_((itc).sk[1], (str), 1) > 0) || \
    (MHD_SCKT_ERR_IS_EAGAIN_(MHD_socket_get_error_())))
 
 /**
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index f33d85a..983267c 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -110,6 +110,15 @@
 #  include <poll.h>
 #endif
 
+#include <stddef.h>
+#if defined(_MSC_FULL_VER) && !defined (_SSIZE_T_DEFINED)
+#  include <stdint.h>
+#  define _SSIZE_T_DEFINED
+   typedef intptr_t ssize_t;
+#endif /* !_SSIZE_T_DEFINED */
+
+#include "mhd_limits.h"
+
 #ifdef _MHD_FD_SETSIZE_IS_DEFAULT
 #  define _MHD_SYS_DEFAULT_FD_SETSIZE FD_SETSIZE
 #else  /* ! _MHD_FD_SETSIZE_IS_DEFAULT */
@@ -153,6 +162,12 @@
 #  define MAYBE_SOCK_NONBLOCK 0
 #endif /* ! HAVE_SOCK_NONBLOCK */
 
+#ifdef MSG_NOSIGNAL
+#  define MAYBE_MSG_NOSIGNAL MSG_NOSIGNAL
+#else  /* ! MSG_NOSIGNAL */
+#  define MAYBE_MSG_NOSIGNAL 0
+#endif /* ! MSG_NOSIGNAL */
+
 #if !defined(SHUT_WR) && defined(SD_SEND)
 #  define SHUT_WR SD_SEND
 #endif
@@ -199,6 +214,15 @@
 #endif
 
 /**
+ * MHD_SCKT_SEND_MAX_SIZE_ is maximum send()/recv() size value.
+ */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_SCKT_SEND_MAX_SIZE_ SSIZE_MAX
+#else
+#  define MHD_SCKT_SEND_MAX_SIZE_ INT_MAX
+#endif
+
+/**
  * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket
  * FDs (W32).  Note that on HP-UNIX, this function may leak the FD if
  * errno is set to EINTR.  Do not use HP-UNIX.
@@ -224,6 +248,29 @@
       MHD_PANIC(_("Close socket failed.\n")); \
   } while(0)
 
+
+/**
+ * MHD_send_ is wrapper for system's send()
+ * @param s the socket to use
+ * @param b the buffer with data to send
+ * @param l the length of data in @a b
+ * @return ssize_t type value
+ */
+#define MHD_send_(s,b,l) \
+  ((ssize_t)send((s),(const void*)(b),((MHD_SCKT_SEND_SIZE_)l), 
MAYBE_MSG_NOSIGNAL))
+
+
+/**
+ * MHD_recv_ is wrapper for system's recv()
+ * @param s the socket to use
+ * @param b the buffer for data to receive
+ * @param l the length of @a b
+ * @return ssize_t type value
+ */
+#define MHD_recv_(s,b,l) \
+  ((ssize_t)recv((s),(void*)(b),((MHD_SCKT_SEND_SIZE_)l), 0))
+
+
 /**
  * Check whether FD can be added to fd_set with specified FD_SETSIZE.
  * @param fd   the fd to check


hooks/post-receive
-- 
GNU libmicrohttpd



reply via email to

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