diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 3e043cfbe..b8887c86e 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -76,6 +76,17 @@ POSSIBILITY OF SUCH DAMAGE. using boost::bind; using libtorrent::total_milliseconds; +void sleep_ms(int milliseconds) +{ +#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN + Sleep(milliseconds); +#elif defined TORRENT_BEOS + snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE); +#else + usleep(milliseconds * 1000); +#endif +} + #ifdef _WIN32 #include @@ -150,7 +161,7 @@ retry: if (ret < 0 && errno != 0 && errno != ETIMEDOUT) { fprintf(stderr, "select failed: %s\n", strerror(errno)); - libtorrent::sleep(500); + sleep_ms(500); } return false; diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index 506d1add3..59f845cce 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -102,6 +102,17 @@ boost::detail::atomic_count num_suggest(0); // the number of requests made from suggested pieces boost::detail::atomic_count num_suggested_requests(0); +void sleep_ms(int milliseconds) +{ +#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN + Sleep(milliseconds); +#elif defined TORRENT_BEOS + snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE); +#else + usleep(milliseconds * 1000); +#endif +} + std::string leaf_path(std::string f) { if (f.empty()) return ""; @@ -1044,7 +1055,7 @@ int main(int argc, char* argv[]) else if (test_mode == dual_test) seed = (i & 1); conns.push_back(new peer_conn(ios[i % num_threads], ti.num_pieces(), ti.piece_length() / 16 / 1024 , ep, (char const*)&ti.info_hash()[0], seed, churn, corrupt)); - libtorrent::sleep(1); + sleep_ms(1); ios[i % num_threads].poll_one(ec); if (ec) {