From 086daf913cd5022d8cf5e165ae08bf565242dd84 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 Aug 2002 12:12:08 +0000 Subject: mr Hartroth correctly pointed out that poll() isn't really that portable so we need to hack around it when not there --- src/config.h.in | 4 ++++ src/main.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/config.h.in b/src/config.h.in index 6ebc04c8a..fdd8f65f7 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -31,3 +31,7 @@ /* Define if you have the `setvbuf' function. */ #undef HAVE_SETVBUF + +/* Define if you have the `poll' function. */ +#undef HAVE_POLL + diff --git a/src/main.c b/src/main.c index 998b1f3e4..a7533a00f 100644 --- a/src/main.c +++ b/src/main.c @@ -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 { -- cgit v1.2.3