Commit 75bfe568 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Circumvent a bug in older glibc.

In glibc prior to 2.3.4 the return value from sem_timedwait is not -1
when it fails, but the actual error code.

Turned out that our ARM setup uses glibc 2.3.2.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1530 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a0a33883
......@@ -634,6 +634,11 @@ bool LinuxSemaphore::Wait(int timeout) {
while (true) {
int result = sem_timedwait(&sem_, &ts);
if (result == 0) return true; // Successfully got semaphore.
if (result > 0) {
// For glibc prior to 2.3.4 sem_timedwait returns the error instead of -1.
errno = result;
result = -1;
}
if (result == -1 && errno == ETIMEDOUT) return false; // Timeout.
CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment