mr Hartroth correctly pointed out that poll() isn't really that portable
authorDaniel Stenberg <daniel@haxx.se>
Tue, 13 Aug 2002 12:12:08 +0000 (12:12 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 13 Aug 2002 12:12:08 +0000 (12:12 +0000)
so we need to hack around it when not there

src/config.h.in
src/main.c

index 6ebc04c8afb11d348783c6d23bf912463c734dc5..fdd8f65f78e8c862ea5e526f71b62a8a8079270b 100644 (file)
@@ -31,3 +31,7 @@
 
 /* Define if you have the `setvbuf' function. */
 #undef HAVE_SETVBUF
+
+/* Define if you have the `poll' function. */
+#undef HAVE_POLL
+
index 998b1f3e4ba2b3f96047c04b95f8f9d85ba10305..a7533a00ffc6edafc3478a7a0e0d07e59adc0b47 100644 (file)
@@ -1878,8 +1878,26 @@ static int parseconfig(const char *filename,
 
 static void go_sleep(long ms)
 {
+#ifdef HAVE_POLL
   /* portable subsecond "sleep" */
   poll((void *)0, 0, ms);
+#else
+  /* systems without poll() need other solutions */
+
+#ifdef WIN32
+  /* Windows offers a millisecond sleep */
+  Sleep(ms);
+#else
+  /* Other systems must use select() for this */
+  struct timeval timeout;
+
+  timeout.tv_sec = 0;
+  timeout.tv_usec = ms * 1000;
+
+  select(0, NULL,  NULL, NULL, &timeout);
+#endif
+
+#endif
 }
 
 struct OutStruct {