Workaround for borked sem_init library function.
This adds a workaround that zeroes out semaphores before they are initialized. Some versions of sem_init (e.g. GLIBC_2.0) fail to fully zero out the semaphore, leading to {errno == ENOSYS} with subsequent sem_timedwait calls. R=machenbach@chromium.org BUG=chromium:536813 LOG=n Review URL: https://codereview.chromium.org/1407463002 Cr-Commit-Position: refs/heads/master@{#31232}
This commit is contained in:
parent
66e5937337
commit
2633401137
@ -75,6 +75,10 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
|
||||
|
||||
Semaphore::Semaphore(int count) {
|
||||
DCHECK(count >= 0);
|
||||
#if V8_LIBC_GLIBC
|
||||
// sem_init in glibc prior to 2.1 does not zero out semaphores.
|
||||
memset(&native_handle_, 0, sizeof(native_handle_));
|
||||
#endif
|
||||
int result = sem_init(&native_handle_, 0, count);
|
||||
DCHECK_EQ(0, result);
|
||||
USE(result);
|
||||
|
Loading…
Reference in New Issue
Block a user