Loading tests/server/sockfilt.c +11 −4 Original line number Diff line number Diff line Loading @@ -399,10 +399,17 @@ static curl_socket_t sockdaemon(curl_socket_t sock, #endif /* ENABLE_IPV6 */ int flag = 1; int rc; int maxretr = 100; if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)) < 0) { rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)); while ((rc < 0) && maxretr) { maxretr--; go_sleep(10); rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)); } if (rc < 0) { perror("setsockopt(SO_REUSEADDR)"); } Loading tests/server/util.c +32 −0 Original line number Diff line number Diff line Loading @@ -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_* Loading Loading @@ -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 } tests/server/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,6 @@ void win32_cleanup(void); /* returns the path name to the test case file */ char *test2file(long testno); void go_sleep(long ms); #endif /* __SERVER_UTIL_H */ Loading
tests/server/sockfilt.c +11 −4 Original line number Diff line number Diff line Loading @@ -399,10 +399,17 @@ static curl_socket_t sockdaemon(curl_socket_t sock, #endif /* ENABLE_IPV6 */ int flag = 1; int rc; int maxretr = 100; if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)) < 0) { rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)); while ((rc < 0) && maxretr) { maxretr--; go_sleep(10); rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag)); } if (rc < 0) { perror("setsockopt(SO_REUSEADDR)"); } Loading
tests/server/util.c +32 −0 Original line number Diff line number Diff line Loading @@ -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_* Loading Loading @@ -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 }
tests/server/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,6 @@ void win32_cleanup(void); /* returns the path name to the test case file */ char *test2file(long testno); void go_sleep(long ms); #endif /* __SERVER_UTIL_H */