---
 nscd/connections.c |    9 ++++++++-
 resolv/res_send.c  |   12 ++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -103,13 +103,13 @@
 #define MAXPACKET       65536
 #endif
 
-
+#ifdef SOCK_NONBLOCK
 #ifndef __ASSUME_SOCK_CLOEXEC
 static int __have_o_nonblock;
 #else
 # define __have_o_nonblock 0
 #endif
-
+#endif
 
 /* From ev_streams.c.  */
 
@@ -917,6 +917,7 @@
 
 		/* only try IPv6 if IPv6 NS and if not failed before */
 		if (nsap->sa_family == AF_INET6 && !statp->ipv6_unavail) {
+#ifdef SOCK_NONBLOCK
 			if (__builtin_expect (__have_o_nonblock >= 0, 1)) {
 				EXT(statp).nssocks[ns] =
 				  socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK,
@@ -929,12 +930,14 @@
 #endif
 			}
 			if (__builtin_expect (__have_o_nonblock < 0, 0))
+#endif
 				EXT(statp).nssocks[ns] =
 				  socket(PF_INET6, SOCK_DGRAM, 0);
 			if (EXT(statp).nssocks[ns] < 0)
 			    statp->ipv6_unavail = errno == EAFNOSUPPORT;
 			slen = sizeof (struct sockaddr_in6);
 		} else if (nsap->sa_family == AF_INET) {
+#ifdef SOCK_NONBLOCK
 			if (__builtin_expect (__have_o_nonblock >= 0, 1)) {
 				EXT(statp).nssocks[ns]
 				  = socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK,
@@ -947,6 +950,7 @@
 #endif
 			}
 			if (__builtin_expect (__have_o_nonblock < 0, 0))
+#endif
 				EXT(statp).nssocks[ns]
 				  = socket(PF_INET, SOCK_DGRAM, 0);
 			slen = sizeof (struct sockaddr_in);
@@ -973,7 +977,11 @@
 			__res_iclose(statp, false);
 			return (0);
 		}
+#ifdef SOCK_NONBLOCK
 		if (__builtin_expect (__have_o_nonblock < 0, 0)) {
+#else
+                {
+#endif
 			/* Make socket non-blocking.  */
 			int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
 			if  (fl != -1)
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -1929,6 +1929,7 @@
 	      /* We have a new incoming connection.  Accept the connection.  */
 	      int fd;
 
+#ifdef SOCK_NONBLOCK
 #ifndef __ASSUME_ACCEPT4
 	      fd = -1;
 	      if (have_accept4 >= 0)
@@ -1945,6 +1946,9 @@
 	      if (have_accept4 < 0)
 		fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL));
 #endif
+#else
+		fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL));
+#endif
 
 	      /* Use the descriptor if we have not reached the limit.  */
 	      if (fd >= 0)
@@ -2164,7 +2168,7 @@
 	  {
 	    /* A new connection.  */
 	    int fd;
-
+#ifdef SOCK_NONBLOCK
 # ifndef __ASSUME_ACCEPT4
 	    fd = -1;
 	    if (have_accept4 >= 0)
@@ -2181,6 +2185,9 @@
 	    if (have_accept4 < 0)
 	      fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL));
 # endif
+#else
+	    fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL));
+#endif
 
 	    /* Use the descriptor if we have not reached the limit.  */
 	    if (fd >= 0)
