commit 0724b181bd61b544b7e27b399711c1fc871e25ea
parent fa6909d5e18a70a8aa01da488634c3d1b643141d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 17 Oct 2016 17:19:29 +0300
Simplify portability by using MHD_recv_() wrapper macro
Diffstat:
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -1072,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? */
@@ -1598,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,
- 0);
+ ret = MHD_recv_ (connection->socket_fd,
+ other,
+ i);
#ifdef EPOLL_SUPPORT
if ( (0 > ret) &&
(MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) )
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
@@ -261,6 +261,17 @@
/**
+ * 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
* @param pset the pointer to fd_set to check or NULL to check