aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-10-01 08:58:03 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-10-01 08:58:03 +0000
commit6ca45beaed85e9e0b320600976be42073d7272f6 (patch)
treec0f7dda7ddfb3af100fdcaa788498b6ec0aa6c9c
parent2a07626aa8dcf601eb575cac4c8817fa0e8e245e (diff)
Added non-blocking sockets test
-rw-r--r--acinclude.m4104
-rw-r--r--configure.in18
2 files changed, 122 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 53abc1471..874a85d4c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,3 +1,107 @@
+dnl Check for how to set a socket to non-blocking state. There seems to exist
+dnl four known different ways, with the one used almost everywhere being POSIX
+dnl and XPG3, while the other different ways for different systems (old BSD,
+dnl Windows and Amiga).
+dnl
+dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
+dnl O_NONBLOCK define is found but does not work. This condition is attempted
+dnl to get caught in this script by using an excessive number of #ifdefs...
+dnl
+AC_DEFUN(CURL_CHECK_NONBLOCKING_SOCKET,
+[
+ AC_MSG_CHECKING([non-blocking sockets style])
+
+ AC_TRY_COMPILE([
+/* headers for O_NONBLOCK test */
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+],[
+/* try to compile O_NONBLOCK */
+
+#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+# if defined(__SVR4) || defined(__srv4__)
+# define PLATFORM_SOLARIS
+# else
+# define PLATFORM_SUNOS4
+# endif
+#endif
+#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
+# define PLATFORM_AIX_V3
+#endif
+
+#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3)
+#error "O_NONBLOCK does not work on this platform"
+#endif
+ int socket;
+ int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
+],[
+dnl the O_NONBLOCK test was fine
+nonblock="O_NONBLOCK"
+AC_DEFINE(HAVE_O_NONBLOCK)
+],[
+dnl the code was bad, try a different program now, test 2
+
+ AC_TRY_COMPILE([
+/* headers for FIONBIO test */
+#include <unistd.h>
+#include <stropts.h>
+],[
+/* FIONBIO source test */
+ int flags = ioctl(socket, FIONBIO, &flags);
+],[
+dnl FIONBIO test was good
+nonblock="FIONBIO"
+AC_DEFINE(HAVE_FIONBIO)
+],[
+dnl FIONBIO test was also bad
+dnl the code was bad, try a different program now, test 3
+
+ AC_TRY_COMPILE([
+/* headers for ioctlsocket test (cygwin?) */
+#include <windows.h>
+],[
+/* ioctlsocket source code */
+ int flags = ioctlsocket(socket, FIONBIO, &flags);
+],[
+dnl ioctlsocket test was good
+nonblock="ioctlsocket"
+AC_DEFINE(HAVE_IOCTLSOCKET)
+],[
+dnl ioctlsocket didnt compile!
+
+ AC_TRY_COMPILE([
+/* headers for IoctlSocket test (Amiga?) */
+#include <sys/ioctl.h>
+],[
+/* IoctlSocket source code */
+ int flags = IoctlSocket(socket, FIONBIO, (long)1);
+],[
+dnl ioctlsocket test was good
+nonblock="IoctlSocket"
+AC_DEFINE(HAVE_IOCTLSOCKET_CASE)
+],[
+dnl ioctlsocket didnt compile!
+nonblock="nada"
+AC_DEFINE(HAVE_DISABLED_NONBLOCKING)
+])
+dnl end of forth test
+
+])
+dnl end of third test
+
+])
+dnl end of second test
+
+])
+dnl end of non-blocking try-compile test
+ AC_MSG_RESULT($nonblock)
+
+ if test "$nonblock" = "nada"; then
+ AC_MSG_WARN([non-block sockets disabled])
+ fi
+])
+
dnl Check for socklen_t: historically on BSD it is an int, and in
dnl POSIX 1g it is a type of its own, but some platforms use different
dnl types for the argument to getsockopt, getpeername, etc. So we
diff --git a/configure.in b/configure.in
index 8fbe508f6..5af823cf6 100644
--- a/configure.in
+++ b/configure.in
@@ -159,6 +159,24 @@ dnl dl lib?
AC_CHECK_FUNC(dlclose, , AC_CHECK_LIB(dl, dlopen))
dnl **********************************************************************
+dnl Check how non-blocking sockets are set
+dnl **********************************************************************
+AC_ARG_ENABLE(nonblocking,
+[ --enable-nonblocking Makes the script detect how to do it
+ --disable-nonblocking Makes the script disable non-blocking sockets],
+[
+ if test "$enableval" = "no" ; then
+ AC_MSG_WARN([non-blocking sockets disabled])
+ AC_DEFINE(HAVE_DISABLED_NONBLOCKING)
+ else
+ CURL_CHECK_NONBLOCKING_SOCKET
+ fi
+],
+[
+ CURL_CHECK_NONBLOCKING_SOCKET
+])
+
+dnl **********************************************************************
dnl Check for the random seed preferences
dnl **********************************************************************