aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-11-13 18:56:55 +0000
committerYang Tse <yangsita@gmail.com>2008-11-13 18:56:55 +0000
commit17d2a464ad42c47ec37870e4b01a18ef5593877f (patch)
tree00948db22881746fb3d2740cd080587694829f56 /lib
parentae6530ee82fc81506ec7c34ffea4fcf3be7c3717 (diff)
Refactor configure script detection of functions used to set sockets into
non-blocking mode, and decouple function detection from function capability.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.netware3
-rw-r--r--lib/config-amigaos.h3
-rw-r--r--lib/config-mac.h3
-rw-r--r--lib/config-os400.h6
-rw-r--r--lib/config-riscos.h6
-rw-r--r--lib/config-symbian.h43
-rw-r--r--lib/config-tpf.h44
-rw-r--r--lib/config-win32.h5
-rw-r--r--lib/config-win32ce.h5
-rw-r--r--lib/config.dos4
-rw-r--r--lib/connect.c55
11 files changed, 104 insertions, 73 deletions
diff --git a/lib/Makefile.netware b/lib/Makefile.netware
index 80476ef0c..a5e0345c9 100644
--- a/lib/Makefile.netware
+++ b/lib/Makefile.netware
@@ -461,12 +461,13 @@ endif
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
@echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
+ @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
+ @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
@echo $(DL)#define HAVE_LL 1$(DL) >> $@
@echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@
@echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
diff --git a/lib/config-amigaos.h b/lib/config-amigaos.h
index f8dc3a374..6a871d047 100644
--- a/lib/config-amigaos.h
+++ b/lib/config-amigaos.h
@@ -29,7 +29,8 @@
#define HAVE_GETHOSTBYADDR 1
#define HAVE_INET_ADDR 1
#define HAVE_INTTYPES_H 1
-#define HAVE_IOCTLSOCKET_CASE 1
+#define HAVE_IOCTLSOCKET_CAMEL 1
+#define HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1
#define HAVE_LIBCRYPTO 1
#define HAVE_LIBSSL 1
#define HAVE_LIBZ 1
diff --git a/lib/config-mac.h b/lib/config-mac.h
index 2f4c2fb02..0547aeaa8 100644
--- a/lib/config-mac.h
+++ b/lib/config-mac.h
@@ -54,7 +54,8 @@
#define HAVE_RAND_STATUS 1
#define HAVE_RAND_EGD 1
-#define HAVE_FIONBIO 1
+#define HAVE_IOCTL 1
+#define HAVE_IOCTL_FIONBIO 1
#define RETSIGTYPE void
diff --git a/lib/config-os400.h b/lib/config-os400.h
index 647893d99..e562b3c0b 100644
--- a/lib/config-os400.h
+++ b/lib/config-os400.h
@@ -394,7 +394,11 @@
#define IOCTL_3_ARGS
-#define HAVE_FIONBIO
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL
+
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
/* to disable LDAP */
#undef CURL_DISABLE_LDAP
diff --git a/lib/config-riscos.h b/lib/config-riscos.h
index f863f634e..fb1bb521e 100644
--- a/lib/config-riscos.h
+++ b/lib/config-riscos.h
@@ -383,7 +383,11 @@
#define IOCTL_3_ARGS
-#define HAVE_FIONBIO
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL
+
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
/* to disable LDAP */
#define CURL_DISABLE_LDAP
diff --git a/lib/config-symbian.h b/lib/config-symbian.h
index 70c2a5803..fb5dd23aa 100644
--- a/lib/config-symbian.h
+++ b/lib/config-symbian.h
@@ -111,9 +111,6 @@
/* Define to 1 if you have the <des.h> header file. */
/* #undef HAVE_DES_H */
-/* disabled non-blocking sockets */
-/* #undef HAVE_DISABLED_NONBLOCKING */
-
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
@@ -129,8 +126,11 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* use FIONBIO for non-blocking sockets */
-#define HAVE_FIONBIO 1
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
/* Define to 1 if you have the `fork' function. */
/*#define HAVE_FORK 1*/
@@ -231,11 +231,23 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
-/* use ioctlsocket() for non-blocking sockets */
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
+/* Define to 1 if you have the ioctlsocket function. */
/* #undef HAVE_IOCTLSOCKET */
-/* use Ioctlsocket() for non-blocking sockets */
-/* #undef HAVE_IOCTLSOCKET_CASE */
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
/* Define to 1 if you have the <io.h> header file. */
/* #undef HAVE_IO_H */
@@ -361,9 +373,6 @@
/* Define to 1 if you have the <openssl/x509.h> header file. */
/*#define HAVE_OPENSSL_X509_H 1*/
-/* use O_NONBLOCK for non-blocking sockets */
-#define HAVE_O_NONBLOCK 1
-
/* Define to 1 if you have the <pem.h> header file. */
/* #undef HAVE_PEM_H */
@@ -427,6 +436,12 @@
/* Define to 1 if you have the `setrlimit' function. */
/*#define HAVE_SETRLIMIT 1*/
+/* Define to 1 if you have the setsockopt function. */
+/* #undef HAVE_SETSOCKOPT */
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
/* Define to 1 if you have the <sgtty.h> header file. */
/*#define HAVE_SGTTY_H 1*/
@@ -454,9 +469,6 @@
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
-/* use SO_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_SO_NONBLOCK */
-
/* Define this if you have the SPNEGO library fbopenssl */
/* #undef HAVE_SPNEGO */
@@ -715,6 +727,9 @@
/* Define if you want to enable c-ares support */
/* #undef USE_ARES */
+/* Define to disable non-blocking sockets */
+/* #undef USE_BLOCKING_SOCKETS */
+
/* if GnuTLS is enabled */
/* #undef USE_GNUTLS */
diff --git a/lib/config-tpf.h b/lib/config-tpf.h
index 35c44ed70..67f9cbfef 100644
--- a/lib/config-tpf.h
+++ b/lib/config-tpf.h
@@ -104,9 +104,6 @@
/* #undef HAVE_DES_H */
#define HAVE_DES_H 1
-/* disabled non-blocking sockets */
-/* #undef HAVE_DISABLED_NONBLOCKING */
-
/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
/* #undef HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
@@ -121,9 +118,11 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* use FIONBIO for non-blocking sockets */
-/* #undef HAVE_FIONBIO */
-#define HAVE_FIONBIO 1
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
/* Define to 1 if you have the `fork' function. */
/* #undef HAVE_FORK */
@@ -217,11 +216,23 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
-/* use ioctlsocket() for non-blocking sockets */
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
+/* Define to 1 if you have the ioctlsocket function. */
/* #undef HAVE_IOCTLSOCKET */
-/* use Ioctlsocket() for non-blocking sockets */
-/* #undef HAVE_IOCTLSOCKET_CASE */
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
/* Define to 1 if you have the <io.h> header file. */
/* #undef HAVE_IO_H */
@@ -328,9 +339,6 @@
/* #undef HAVE_OPENSSL_X509_H */
#define HAVE_OPENSSL_X509_H 1
-/* use O_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_O_NONBLOCK 1 */
-
/* Define to 1 if you have the <pem.h> header file. */
/* #undef HAVE_PEM_H */
#define HAVE_PEM_H 1
@@ -380,6 +388,12 @@
/* Define to 1 if you have the `setrlimit' function. */
#define HAVE_SETRLIMIT 1
+/* Define to 1 if you have the setsockopt function. */
+/* #undef HAVE_SETSOCKOPT */
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
/* Define to 1 if you have the <sgtty.h> header file. */
/* #undef HAVE_SGTTY_H 1 */
@@ -407,9 +421,6 @@
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
-/* use SO_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_SO_NONBLOCK */
-
/* Define this if you have the SPNEGO library fbopenssl */
/* #undef HAVE_SPNEGO */
@@ -602,6 +613,9 @@
/* Define if you want to enable ares support */
/* #undef USE_ARES */
+/* Define to disable non-blocking sockets */
+/* #undef USE_BLOCKING_SOCKETS */
+
/* if GnuTLS is enabled */
/* #undef USE_GNUTLS */
diff --git a/lib/config-win32.h b/lib/config-win32.h
index 88d011849..dc359d6a3 100644
--- a/lib/config-win32.h
+++ b/lib/config-win32.h
@@ -157,9 +157,12 @@
/* Define if you have the inet_addr function. */
#define HAVE_INET_ADDR 1
-/* Define if you have the ioctlsocket function. */
+/* Define if you have the ioctlsocket function. */
#define HAVE_IOCTLSOCKET 1
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
/* Define if you have the perror function. */
#define HAVE_PERROR 1
diff --git a/lib/config-win32ce.h b/lib/config-win32ce.h
index b770a4472..cd793d6cc 100644
--- a/lib/config-win32ce.h
+++ b/lib/config-win32ce.h
@@ -145,9 +145,12 @@
/* Define if you have the inet_addr function. */
#define HAVE_INET_ADDR 1
-/* Define if you have the ioctlsocket function. */
+/* Define if you have the ioctlsocket function. */
#define HAVE_IOCTLSOCKET 1
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
/* Define if you have the perror function. */
#define HAVE_PERROR 1
diff --git a/lib/config.dos b/lib/config.dos
index 16ed9d6a0..361daba2c 100644
--- a/lib/config.dos
+++ b/lib/config.dos
@@ -19,13 +19,15 @@
#define HAVE_ARPA_INET_H 1
#define HAVE_FCNTL_H 1
-#define HAVE_FIONBIO 1
#define HAVE_GETADDRINFO 1
#define HAVE_GETNAMEINFO 1
#define HAVE_GETPROTOBYNAME 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_IO_H 1
+#define HAVE_IOCTL 1
+#define HAVE_IOCTL_FIONBIO 1
#define HAVE_IOCTLSOCKET 1
+#define HAVE_IOCTLSOCKET_FIONBIO 1
#define HAVE_LOCALE_H 1
#define HAVE_LONGLONG 1
#define HAVE_MEMORY_H 1
diff --git a/lib/connect.c b/lib/connect.c
index 65e9be4f4..f2b15da82 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -59,7 +59,7 @@
#include <stdlib.h> /* required for free() prototype, without it, this crashes */
#endif /* on macos 68K */
-#if (defined(HAVE_FIONBIO) && defined(NETWARE))
+#if (defined(HAVE_IOCTL_FIONBIO) && defined(NETWARE))
#include <sys/filio.h>
#endif
#ifdef NETWARE
@@ -189,64 +189,47 @@ long Curl_timeleft(struct connectdata *conn,
int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
int nonblock /* TRUE or FALSE */)
{
-#undef SETBLOCK
-#define SETBLOCK 0
-#ifdef HAVE_O_NONBLOCK
+#if defined(USE_BLOCKING_SOCKETS)
+
+ return 0; /* returns success */
+
+#elif defined(HAVE_FCNTL_O_NONBLOCK)
+
/* most recent unix versions */
int flags;
-
flags = fcntl(sockfd, F_GETFL, 0);
if(FALSE != nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
-#undef SETBLOCK
-#define SETBLOCK 1
-#endif
-#if defined(HAVE_FIONBIO) && (SETBLOCK == 0)
+#elif defined(HAVE_IOCTL_FIONBIO)
+
/* older unix versions */
int flags;
-
flags = nonblock;
return ioctl(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 2
-#endif
-#if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0)
- /* Windows? */
+#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
+
+ /* Windows */
unsigned long flags;
flags = nonblock;
-
return ioctlsocket(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 3
-#endif
-#if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0)
- /* presumably for Amiga */
+#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
+
+ /* Amiga */
return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
-#undef SETBLOCK
-#define SETBLOCK 4
-#endif
-#if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0)
+#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)
+
/* BeOS */
long b = nonblock ? 1 : 0;
return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
-#undef SETBLOCK
-#define SETBLOCK 5
-#endif
-#ifdef HAVE_DISABLED_NONBLOCKING
- return 0; /* returns success */
-#undef SETBLOCK
-#define SETBLOCK 6
-#endif
-
-#if(SETBLOCK == 0)
-#error "no non-blocking method was found/used/set"
+#else
+# error "no non-blocking method was found/used/set"
#endif
}