summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2014-12-23 13:57:23 -0800
committerJesse Hall <jessehall@google.com>2015-01-10 15:41:01 -0800
commitfcd15b478c20f579388bb1368f05098dca534639 (patch)
tree3efdd0440f567d9e62a231d21a659e721e16d100 /services
parent033f7e8e35ac76404fe823a67e07ba7c42bc357c (diff)
downloadframeworks_native-fcd15b478c20f579388bb1368f05098dca534639.zip
frameworks_native-fcd15b478c20f579388bb1368f05098dca534639.tar.gz
frameworks_native-fcd15b478c20f579388bb1368f05098dca534639.tar.bz2
surfaceflinger: use Mutex timedLock instead of tryLock loop
Rather than trying to acquire the state lock without waiting three times at 1 second intervals in SurfaceFlinger::dump(), just try to acquire the lock once with a 1 second timeout. Avoids spurious mutex acquire failures that lead to flaky com.android.cts.jank.opengl.CtsHostJankOpenGl results. Bug: 18842510 Change-Id: I00ce6109647de2aef8831dd2f8fa98652ba7f4e0
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8daf0f9..6a5a39e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2359,18 +2359,15 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
result.appendFormat("Permission Denial: "
"can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
} else {
- // Try to get the main lock, but don't insist if we can't
+ // Try to get the main lock, but give up after one second
// (this would indicate SF is stuck, but we want to be able to
// print something in dumpsys).
- int retry = 3;
- while (mStateLock.tryLock()<0 && --retry>=0) {
- usleep(1000000);
- }
- const bool locked(retry >= 0);
+ status_t err = mStateLock.timedLock(s2ns(1));
+ bool locked = (err == NO_ERROR);
if (!locked) {
- result.append(
- "SurfaceFlinger appears to be unresponsive, "
- "dumping anyways (no locks held)\n");
+ result.appendFormat(
+ "SurfaceFlinger appears to be unresponsive (%s [%d]), "
+ "dumping anyways (no locks held)\n", strerror(-err), err);
}
bool dumpAll = true;