libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 744e4d4ba089b1d50c64d9d8c9cef033110c2839
parent 1237879c31ce32aeb9f656addb8983529e251fc2
Author: Nils Durner <durner@gnunet.org>
Date:   Thu, 17 Dec 2009 19:29:17 +0000

Don't depend on poll.h

Diffstat:
MChangeLog | 3+++
Mconfigure.ac | 2+-
Msrc/daemon/daemon.c | 18+++++++++++++++++-
3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,6 @@ +Thu Dec 17 20:26:52 CET 2009 + poll.h is not stricly required anymore. -ND + Fri Dec 4 13:17:50 CET 2009 Adding MHD_OPTION_ARRAY. -CG diff --git a/configure.ac b/configure.ac @@ -145,7 +145,7 @@ AC_SUBST(PTHREAD_CPPFLAGS) AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) # Check for optional headers -AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h]) +AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h poll.h]) AC_CHECK_FUNCS(memmem) diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -36,7 +36,9 @@ #include "gnutls_global.h" #endif +#ifdef HAVE_POLL_H #include <poll.h> +#endif /** * Default connection limit. @@ -490,7 +492,9 @@ MHD_handle_connection (void *data) unsigned int timeout; time_t now; struct MHD_Pollfd mp; +#ifdef HAVE_POLL_H struct pollfd p; +#endif timeout = con->daemon->connection_timeout; while ((!con->daemon->shutdown) && (con->socket_fd != -1)) { @@ -513,7 +517,11 @@ MHD_handle_connection (void *data) { tv.tv_sec = 0; } +#ifdef HAVE_POLL_H if (0 == (con->daemon->options & MHD_USE_POLL)) { +#else + { +#endif /* use select */ FD_ZERO (&rs); FD_ZERO (&ws); @@ -537,7 +545,10 @@ MHD_handle_connection (void *data) con->write_handler (con); if (con->socket_fd != -1) con->idle_handler (con); - } else { + } +#ifdef HAVE_POLL_H + else + { /* use poll */ memset(&mp, 0, sizeof (struct MHD_Pollfd)); MHD_connection_get_pollfd(con, &mp); @@ -570,6 +581,7 @@ MHD_handle_connection (void *data) (0 != (p.revents & (POLLERR | POLLHUP))) ) MHD_connection_close (con, MHD_REQUEST_TERMINATED_WITH_ERROR); } +#endif } if (con->socket_fd != -1) { @@ -1044,6 +1056,7 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) static int MHD_poll (struct MHD_Daemon *daemon) { +#ifdef HAVE_POLL_H struct pollfd p; if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) @@ -1068,6 +1081,9 @@ MHD_poll (struct MHD_Daemon *daemon) if (0 != (p.revents & POLLIN)) MHD_accept_connection (daemon); return MHD_YES; +#else + return MHD_NO; +#endif } /**