From 386aa98c4ffb9b805303e683f0a7b925b44d04db Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 7 Nov 2011 21:58:03 -0800 Subject: [PATCH] Fix an issue where we could wait for a non-existing transaction This fixes the issue: "Call not sent" dialog takes too long to dismiss after hitting OK" Note: the system would recover after a 5 second timeout. Bug: 5534520 Change-Id: Ifa37e594b50581f498479a5858672441b3d7dd87 --- services/surfaceflinger/SurfaceFlinger.cpp | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 8f4fdb8fe..1b00e9380 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1217,23 +1217,25 @@ void SurfaceFlinger::setTransactionState(const Vector& state, sp client( static_cast(s.client.get()) ); transactionFlags |= setClientStateLocked(client, s.state); } - if (transactionFlags) { - setTransactionFlags(transactionFlags); - } - // if this is a synchronous transaction, wait for it to take effect before - // returning. - if (flags & eSynchronous) { - mTransationPending = true; - } - while (mTransationPending) { - status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); - if (CC_UNLIKELY(err != NO_ERROR)) { - // just in case something goes wrong in SF, return to the - // called after a few seconds. - LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!"); - mTransationPending = false; - break; + if (transactionFlags) { + // this triggers the transaction + setTransactionFlags(transactionFlags); + + // if this is a synchronous transaction, wait for it to take effect + // before returning. + if (flags & eSynchronous) { + mTransationPending = true; + } + while (mTransationPending) { + status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); + if (CC_UNLIKELY(err != NO_ERROR)) { + // just in case something goes wrong in SF, return to the + // called after a few seconds. + LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!"); + mTransationPending = false; + break; + } } } }