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
This commit is contained in:
parent
a0a3388363
commit
75bfe56832
@ -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.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user