aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_process.c
diff options
context:
space:
mode:
Diffstat (limited to 'ares/ares_process.c')
-rw-r--r--ares/ares_process.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c
index b7f375e19..05341aa64 100644
--- a/ares/ares_process.c
+++ b/ares/ares_process.c
@@ -805,68 +805,51 @@ void ares__send_query(ares_channel channel, struct query *query,
static int setsocknonblock(ares_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)
+#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
+
#ifdef WATT32
char flags;
#else
- /* Windows? */
+ /* Windows */
unsigned long flags;
#endif
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
}