Merge "surfaceflinger: use Mutex timedLock instead of tryLock loop"

This commit is contained in:
Jesse Hall 2015-01-12 23:33:06 +00:00 committed by Gerrit Code Review
commit 5b730570be

View File

@ -2359,18 +2359,15 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
result.appendFormat("Permission Denial: " result.appendFormat("Permission Denial: "
"can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid); "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
} else { } 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 // (this would indicate SF is stuck, but we want to be able to
// print something in dumpsys). // print something in dumpsys).
int retry = 3; status_t err = mStateLock.timedLock(s2ns(1));
while (mStateLock.tryLock()<0 && --retry>=0) { bool locked = (err == NO_ERROR);
usleep(1000000);
}
const bool locked(retry >= 0);
if (!locked) { if (!locked) {
result.append( result.appendFormat(
"SurfaceFlinger appears to be unresponsive, " "SurfaceFlinger appears to be unresponsive (%s [%d]), "
"dumping anyways (no locks held)\n"); "dumping anyways (no locks held)\n", strerror(-err), err);
} }
bool dumpAll = true; bool dumpAll = true;