diff options
author | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 00:17:41 +0000 |
---|---|---|
committer | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 00:17:41 +0000 |
commit | 1944bd79ef73c413063b052f0cac92ef2bbf2720 (patch) | |
tree | d8b76af817721496ade127976af8a2e8c35dd2b1 /net/base | |
parent | 7ae1b97cae65107ca09124e98365e4de9ddec32d (diff) | |
download | chromium_src-1944bd79ef73c413063b052f0cac92ef2bbf2720.zip chromium_src-1944bd79ef73c413063b052f0cac92ef2bbf2720.tar.gz chromium_src-1944bd79ef73c413063b052f0cac92ef2bbf2720.tar.bz2 |
Using PlatformThread::Sleep instead of msleep
(lgtm already in codereview 13237)
Review URL: http://codereview.chromium.org/16589
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/listen_socket_unittest.cc | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/net/base/listen_socket_unittest.cc b/net/base/listen_socket_unittest.cc index 99a82c5..aaac099 100644 --- a/net/base/listen_socket_unittest.cc +++ b/net/base/listen_socket_unittest.cc @@ -18,20 +18,6 @@ static const int kDefaultTimeoutMs = 5000; static const char* kSemaphoreName = "chromium.listen_socket"; #endif -// millisecond sleep -static void msleep(unsigned long milisec) { -#if defined(OS_WIN) - Sleep(milisec); -#elif defined(OS_POSIX) - struct timespec req = {0}; - time_t sec = (int)(milisec / 1000); - milisec = milisec - (sec * 1000); - req.tv_sec = sec; - req.tv_nsec = milisec * 1000000L; - while (nanosleep(&req, &req) == -1) - continue; -#endif -} ListenSocket* ListenSocketTester::DoListen() { return ListenSocket::Listen(kLoopback, kTestPort, this); @@ -142,7 +128,7 @@ bool ListenSocketTester::NextAction(int timeout) { return false; while (true) { int result = sem_trywait(semaphore_); - msleep(1); // 1ms sleep + PlatformThread::Sleep(1); // 1MS sleep timeout--; if (timeout <= 0) return false; @@ -175,7 +161,7 @@ int ListenSocketTester::ClearTestSocket() { if (len == SOCKET_ERROR) { if (errno == EWOULDBLOCK || errno == EAGAIN) { #endif - msleep(1); + PlatformThread::Sleep(1); time_out++; if (time_out > 10) break; @@ -280,7 +266,7 @@ void ListenSocketTester::TestServerSend() { // of the time. I could fix this by making the socket blocking, but then // this test might hang in the case of errors. It would be nice to do // something that felt more reliable here. - msleep(10); // sleep for 10ms + PlatformThread::Sleep(10); // sleep for 10ms const int buf_len = 200; char buf[buf_len+1]; int recv_len = recv(test_socket_, buf, buf_len, 0); |