diff options
| author | 2018-10-17 16:03:42 -0700 | |
|---|---|---|
| committer | 2018-10-17 16:03:42 -0700 | |
| commit | 2d899c41ac389ab881a56a82380e7bdb91fbbcc8 (patch) | |
| tree | cc0a13d666ad7b767f76261e1917a1f7039d8cd6 | |
| parent | 6e82b7e6726d2c2ed0d6754ce1557d00e051b52c (diff) | |
Fix usages of TEMP_FAILURE_RETRY(pthread_foo(...)).
pthread functions don't return -1 and set errno on failure, they return
a positive errno value instead.
Test: treehugger
Change-Id: I0097660e44c86c4c49d642e1169a30e43f9662bf
| -rw-r--r-- | dex2oat/dex2oat.cc | 6 | ||||
| -rw-r--r-- | runtime/base/mutex.cc | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index b4aa327645..8737927997 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -590,8 +590,10 @@ class WatchDog { const char* reason = "dex2oat watch dog thread waiting"; CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason); while (!shutting_down_) { - int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &mutex_, &timeout_ts)); - if (rc == ETIMEDOUT) { + int rc = pthread_cond_timedwait(&cond_, &mutex_, &timeout_ts); + if (rc == EINTR) { + continue; + } else if (rc == ETIMEDOUT) { Fatal(StringPrintf("dex2oat did not finish after %" PRId64 " seconds", timeout_in_milliseconds_/1000)); } else if (rc != 0) { diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index b2ddff3f6a..c11e3d1e6e 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -1028,7 +1028,11 @@ bool ConditionVariable::TimedWait(Thread* self, int64_t ms, int32_t ns) { guard_.recursion_count_ = 0; timespec ts; InitTimeSpec(true, clock, ms, ns, &ts); - int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &guard_.mutex_, &ts)); + int rc; + while ((rc = pthread_cond_timedwait(&cond_, &guard_.mutex_, &ts)) == EINTR) { + continue; + } + if (rc == ETIMEDOUT) { timed_out = true; } else if (rc != 0) { |