Correctly handle EINTR return from futex
We should handle EINTR the same way we do EAGAIN: they're both
transient failures. Either way, higher-level code (see
ReaderWriterMutex::SharedLock) will do the right thing, loop around,
and try again.
Test: code inspection
Change-Id: I1eb7fb6851cc1a65acc9a0cf7cbeef787b6b28b6
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 5d92298..48125aa 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -672,7 +672,7 @@
ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self));
++num_pending_readers_;
if (futex(state_.Address(), FUTEX_WAIT, cur_state, nullptr, nullptr, 0) != 0) {
- if (errno != EAGAIN) {
+ if (errno != EAGAIN && errno != EINTR) {
PLOG(FATAL) << "futex wait failed for " << name_;
}
}
@@ -796,7 +796,7 @@
reinterpret_cast<const timespec*>(std::numeric_limits<int32_t>::max()),
guard_.state_.Address(), cur_sequence) != -1;
if (!done) {
- if (errno != EAGAIN) {
+ if (errno != EAGAIN && errno != EINTR) {
PLOG(FATAL) << "futex cmp requeue failed for " << name_;
}
}