]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
bug #1639: Implement a pselect() wrapper around select() for OpenBSD
authorMukund Sivaraman <muks@isc.org>
Mon, 19 Mar 2012 18:47:20 +0000 (00:17 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 21 Mar 2012 04:38:09 +0000 (10:08 +0530)
configure.ac
tests/tools/perfdhcp/perfdhcp.c

index 5ce897df057341301307c23f7c367074718a50bd..a288c59c48fba03d2ae5b80796882d680adb1bce 100644 (file)
@@ -930,6 +930,9 @@ EV_SET(&kevent, 0, 0, 0, 0, 0, udata);],
        ])
 fi
 
+# Check for pselect() for use in perfdhcp
+AC_CHECK_FUNCS([pselect])
+
 # perfdhcp: If the clock_gettime() function does not exist on the system,
 # use an alternative supplied in the code based on gettimeofday().
 CLOCK_GETTIME_LDFLAGS=
index 6e02b7e8697dc18c0b817066af5ffb1abbd041b1..99145a7cb56787d0ecd7d4229cd4f8c914f430f8 100644 (file)
@@ -66,6 +66,35 @@ main(const int argc, char* const argv[])
 #include <time.h>
 #include <unistd.h>
 
+#ifndef HAVE_PSELECT
+
+#include <assert.h>
+
+/* Platforms such as OpenBSD don't provide a pselect(), so we use our
+   own implementation for this testcase, which wraps around select() and
+   hence doesn't implement the high precision timer. This implementation
+   is fine for our purpose. */
+
+static int
+pselect (int nfds, fd_set *readfds, fd_set *writefds,
+         fd_set *exceptfds, const struct timespec *timeout,
+         const sigset_t *sigmask)
+{
+    struct timeval my_timeout;
+
+    /* Our particular usage of pselect() doesn't use these fields. */
+    assert(writefds == NULL);
+    assert(exceptfds == NULL);
+    assert(sigmask == NULL);
+
+    my_timeout.tv_sec = timeout->tv_sec;
+    my_timeout.tv_usec = timeout->tv_nsec / 1000;
+
+    return select(nfds, readfds, writefds, exceptfds, &my_timeout);
+}
+
+#endif
+
 /* DHCPv4 defines (to be moved/shared) */
 
 #define DHCP_OFF_OPCODE                0