[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37770 - libmicrohttpd/src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37770 - libmicrohttpd/src/microhttpd |
Date: |
Tue, 23 Aug 2016 22:13:23 +0200 |
Author: Karlson2k
Date: 2016-08-23 22:13:23 +0200 (Tue, 23 Aug 2016)
New Revision: 37770
Modified:
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/microhttpd/mhd_sockets.c
libmicrohttpd/src/microhttpd/mhd_sockets.h
Log:
Moved add_to_fd_set() to mhd_sockets.c, simplified return value
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2016-08-23 20:13:19 UTC (rev
37769)
+++ libmicrohttpd/src/microhttpd/daemon.c 2016-08-23 20:13:23 UTC (rev
37770)
@@ -634,34 +634,6 @@
#endif
-/**
- * Add @a fd to the @a set. If @a fd is
- * greater than @a max_fd, set @a max_fd to @a fd.
- *
- * @param fd file descriptor to add to the @a set
- * @param set set to modify
- * @param max_fd maximum value to potentially update
- * @param fd_setsize value of FD_SETSIZE
- * @return #MHD_YES on success, #MHD_NO otherwise
- */
-static int
-add_to_fd_set (MHD_socket fd,
- fd_set *set,
- MHD_socket *max_fd,
- unsigned int fd_setsize)
-{
- if (NULL == set || MHD_INVALID_SOCKET == fd)
- return MHD_NO;
- if (!MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd, set, fd_setsize))
- return MHD_NO;
- MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd, set, fd_setsize);
- if ( (NULL != max_fd) &&
- ((fd > *max_fd) || (MHD_INVALID_SOCKET == *max_fd)) )
- *max_fd = fd;
-
- return MHD_YES;
-}
-
#undef MHD_get_fdset
/**
@@ -740,11 +712,11 @@
/* we're in epoll mode, use the epoll FD as a stand-in for
the entire event set */
- return add_to_fd_set (daemon->epoll_fd, read_fd_set, max_fd, fd_setsize);
+ return MHD_add_to_fd_set_ (daemon->epoll_fd, read_fd_set, max_fd,
fd_setsize) ? MHD_YES : MHD_NO;
}
#endif
if (MHD_INVALID_SOCKET != daemon->socket_fd &&
- MHD_YES != add_to_fd_set (daemon->socket_fd, read_fd_set, max_fd,
fd_setsize))
+ !MHD_add_to_fd_set_ (daemon->socket_fd, read_fd_set, max_fd, fd_setsize))
result = MHD_NO;
for (pos = daemon->connections_head; NULL != pos; pos = pos->next)
@@ -752,19 +724,19 @@
switch (pos->event_loop_info)
{
case MHD_EVENT_LOOP_INFO_READ:
- if (MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
+ if (!MHD_add_to_fd_set_ (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
result = MHD_NO;
break;
case MHD_EVENT_LOOP_INFO_WRITE:
- if (MHD_YES != add_to_fd_set (pos->socket_fd, write_fd_set, max_fd,
fd_setsize))
+ if (!MHD_add_to_fd_set_ (pos->socket_fd, write_fd_set, max_fd,
fd_setsize))
result = MHD_NO;
if (pos->read_buffer_size > pos->read_buffer_offset &&
- MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
+ !MHD_add_to_fd_set_ (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
result = MHD_NO;
break;
case MHD_EVENT_LOOP_INFO_BLOCK:
if (pos->read_buffer_size > pos->read_buffer_offset &&
- MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
+ !MHD_add_to_fd_set_ (pos->socket_fd, read_fd_set, max_fd,
fd_setsize))
result = MHD_NO;
break;
case MHD_EVENT_LOOP_INFO_CLEANUP:
@@ -915,23 +887,19 @@
switch (con->event_loop_info)
{
case MHD_EVENT_LOOP_INFO_READ:
- if (MHD_YES !=
- add_to_fd_set (con->socket_fd, &rs, &maxsock, FD_SETSIZE))
+ if (!MHD_add_to_fd_set_ (con->socket_fd, &rs, &maxsock,
FD_SETSIZE))
err_state = 1;
break;
case MHD_EVENT_LOOP_INFO_WRITE:
- if (MHD_YES !=
- add_to_fd_set (con->socket_fd, &ws, &maxsock, FD_SETSIZE))
+ if (!MHD_add_to_fd_set_ (con->socket_fd, &ws, &maxsock,
FD_SETSIZE))
err_state = 1;
if ( (con->read_buffer_size > con->read_buffer_offset) &&
- (MHD_YES !=
- add_to_fd_set (con->socket_fd, &rs, &maxsock, FD_SETSIZE))
)
+ (!MHD_add_to_fd_set_ (con->socket_fd, &rs, &maxsock,
FD_SETSIZE)) )
err_state = 1;
break;
case MHD_EVENT_LOOP_INFO_BLOCK:
if ( (con->read_buffer_size > con->read_buffer_offset) &&
- (MHD_YES !=
- add_to_fd_set (con->socket_fd, &rs, &maxsock, FD_SETSIZE))
)
+ (!MHD_add_to_fd_set_ (con->socket_fd, &rs, &maxsock,
FD_SETSIZE)) )
err_state = 1;
tv.tv_sec = 0;
tv.tv_usec = 0;
@@ -944,8 +912,7 @@
#if WINDOWS
if (MHD_INVALID_PIPE_ != spipe)
{
- if (MHD_YES !=
- add_to_fd_set (spipe, &rs, &maxsock, FD_SETSIZE))
+ if (!MHD_add_to_fd_set_ (spipe, &rs, &maxsock, FD_SETSIZE))
err_state = 1;
}
#endif
@@ -2339,10 +2306,10 @@
{
/* accept only, have one thread per connection */
if ( (MHD_INVALID_SOCKET != daemon->socket_fd) &&
- (MHD_YES != add_to_fd_set (daemon->socket_fd,
- &rs,
- &maxsock,
- FD_SETSIZE)) )
+ (!MHD_add_to_fd_set_ (daemon->socket_fd,
+ &rs,
+ &maxsock,
+ FD_SETSIZE)) )
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon, "Could not add listen socket to fdset");
@@ -2351,10 +2318,10 @@
}
}
if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) &&
- (MHD_YES != add_to_fd_set (daemon->wpipe[0],
- &rs,
- &maxsock,
- FD_SETSIZE)) )
+ (!MHD_add_to_fd_set_ (daemon->wpipe[0],
+ &rs,
+ &maxsock,
+ FD_SETSIZE)) )
{
#if defined(MHD_WINSOCK_SOCKETS)
/* fdset limit reached, new connections
@@ -2363,10 +2330,10 @@
if (MHD_INVALID_SOCKET != daemon->socket_fd)
{
FD_CLR (daemon->socket_fd, &rs);
- if (MHD_YES != add_to_fd_set (daemon->wpipe[0],
- &rs,
- &maxsock,
- FD_SETSIZE))
+ if (!MHD_add_to_fd_set_ (daemon->wpipe[0],
+ &rs,
+ &maxsock,
+ FD_SETSIZE))
{
#endif /* MHD_WINSOCK_SOCKETS */
#ifdef HAVE_MESSAGES
Modified: libmicrohttpd/src/microhttpd/mhd_sockets.c
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_sockets.c 2016-08-23 20:13:19 UTC (rev
37769)
+++ libmicrohttpd/src/microhttpd/mhd_sockets.c 2016-08-23 20:13:23 UTC (rev
37770)
@@ -235,3 +235,32 @@
#endif /* MHD_WINSOCK_SOCKETS */
+
+
+/**
+ * Add @a fd to the @a set. If @a fd is
+ * greater than @a max_fd, set @a max_fd to @a fd.
+ *
+ * @param fd file descriptor to add to the @a set
+ * @param set set to modify
+ * @param max_fd maximum value to potentially update
+ * @param fd_setsize value of FD_SETSIZE
+ * @return non-zero if succeeded, zero otherwise
+ */
+int
+MHD_add_to_fd_set_ (MHD_socket fd,
+ fd_set *set,
+ MHD_socket *max_fd,
+ unsigned int fd_setsize)
+{
+ if (NULL == set || MHD_INVALID_SOCKET == fd)
+ return 0;
+ if (!MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd, set, fd_setsize))
+ return 0;
+ MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd, set, fd_setsize);
+ if ( (NULL != max_fd) &&
+ ((fd > *max_fd) || (MHD_INVALID_SOCKET == *max_fd)) )
+ *max_fd = fd;
+
+ return !0;
+}
Modified: libmicrohttpd/src/microhttpd/mhd_sockets.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_sockets.h 2016-08-23 20:13:19 UTC (rev
37769)
+++ libmicrohttpd/src/microhttpd/mhd_sockets.h 2016-08-23 20:13:23 UTC (rev
37770)
@@ -569,4 +569,21 @@
# define MHD_socket_set_error_to_ENOMEM()
MHD_socket_set_error_(MHD_SCKT_ENOMEM_)
#endif
+/* Socket functions */
+
+/**
+ * Add @a fd to the @a set. If @a fd is
+ * greater than @a max_fd, set @a max_fd to @a fd.
+ *
+ * @param fd file descriptor to add to the @a set
+ * @param set set to modify
+ * @param max_fd maximum value to potentially update
+ * @param fd_setsize value of FD_SETSIZE
+ * @return non-zero if succeeded, zero otherwise
+ */
+int
+MHD_add_to_fd_set_ (MHD_socket fd,
+ fd_set *set,
+ MHD_socket *max_fd,
+ unsigned int fd_setsize);
#endif /* ! MHD_SOCKETS_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37770 - libmicrohttpd/src/microhttpd,
gnunet <=