summaryrefslogtreecommitdiff
path: root/tests/server/util.c
diff options
context:
space:
mode:
authorGunter Knauf <gk@gknw.de>2007-07-12 01:07:49 +0000
committerGunter Knauf <gk@gknw.de>2007-07-12 01:07:49 +0000
commit0878b14f79ffc967c1bde19bbda1d6363d05172d (patch)
treecd67e8df39f016c5dce11f9fcb4648057156efd9 /tests/server/util.c
parent7d56f353884bb46ddd4e1dd31bbd693142ccc44c (diff)
downloadcurl-0878b14f79ffc967c1bde19bbda1d6363d05172d.tar.gz
added time loop to sockfilt.c in order to wait for SO_REUSEADDR;
added go_sleep() to util.c.
Diffstat (limited to 'tests/server/util.c')
-rw-r--r--tests/server/util.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/server/util.c b/tests/server/util.c
index 080ef4759..8017081fa 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -45,6 +45,9 @@
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
+#ifdef HAVE_SYS_POLL_H
+#include <sys/poll.h>
+#endif
#define ENABLE_CURLX_PRINTF
/* make the curlx header define all printf() functions to use the curlx_*
@@ -159,3 +162,32 @@ char *test2file(long testno)
snprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno);
return filename;
}
+
+void go_sleep(long ms)
+{
+#ifdef HAVE_POLL_FINE
+ /* portable subsecond "sleep" */
+ poll((void *)0, 0, (int)ms);
+#else
+ /* systems without poll() need other solutions */
+
+#ifdef WIN32
+ /* Windows offers a millisecond sleep */
+ Sleep(ms);
+#elif defined(MSDOS)
+ delay(ms);
+#else
+ /* Other systems must use select() for this */
+ struct timeval timeout;
+
+ timeout.tv_sec = ms/1000;
+ ms = ms%1000;
+ timeout.tv_usec = ms * 1000;
+
+ select(0, NULL, NULL, NULL, &timeout);
+#endif
+
+#endif
+}
+
+