From 92f027fc4337d0578043937cb4b64a5a01e85e96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 13 Sep 2018 15:00:00 +0200
Subject: [PATCH] Stdio.UDP [NT]: Fix wait() failing with ENOTSOCK on NT.

It helps if you use the correct macros to handle the fd sets...

Fixes [PIKE-129].
---
 .gitattributes          | 1 -
 src/modules/files/udp.c | 8 ++++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 6849b07cec..6477c289d7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -718,7 +718,6 @@ testfont binary
 /src/modules/files/stat.c foreign_ident
 /src/modules/files/termios.c foreign_ident
 /src/modules/files/termios_flags.h foreign_ident
-/src/modules/files/udp.c foreign_ident
 /src/modules/math/Makefile.in foreign_ident
 /src/modules/math/configure.in foreign_ident
 /src/modules/math/math.c foreign_ident
diff --git a/src/modules/files/udp.c b/src/modules/files/udp.c
index 655be3ba6e..7cab6e162f 100644
--- a/src/modules/files/udp.c
+++ b/src/modules/files/udp.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: udp.c,v 1.72 2005/09/14 12:51:19 grubba Exp $
+|| $Id$
 */
 
 #define NO_PIKE_SHORTHAND
@@ -496,8 +496,8 @@ void udp_wait(INT32 args)
 #else /* !HAVE_POLL */
   THREADS_ALLOW();
 
-  FD_ZERO(&rset);
-  FD_SET(fd, &rset);
+  fd_FD_ZERO(&rset);
+  fd_FD_SET(fd, &rset);
   tv.tv_sec = DO_NOT_WARN((int)timeout);
   tv.tv_usec = DO_NOT_WARN((int)((timeout - ((int)timeout)) * 1000000.0));
   res = fd_select(fd+1, &rset, NULL, NULL, &tv);
@@ -511,7 +511,7 @@ void udp_wait(INT32 args)
     Pike_error("udp->wait(): select() failed with errno %d\n", e);
   } else {
     /* Success? */
-    if (FD_ISSET(fd, &rset)) {
+    if (fd_FD_ISSET(fd, &rset)) {
       res = 1;
     } else {
       res = 0;
-- 
GitLab