OSDN Git Service

Fix a race in SurfaceFlinger that could cause layers to be leaked forever.
authorMathias Agopian <mathias@google.com>
Wed, 4 May 2011 00:04:02 +0000 (17:04 -0700)
committerMathias Agopian <mathias@google.com>
Mon, 23 May 2011 23:13:20 +0000 (16:13 -0700)
commit34cd9b72f1474ccbfd2338049d81a24bfa814f35
treed6dac0941c782837c7237947ebdca29f287ce344
parent02cf75e0ca7e37c0f92b31d965eb41006d849962
Fix a race in SurfaceFlinger that could cause layers to be leaked forever.

The transaction flags were atomically read-and-cleared to determine if
a transaction was needed, in the later case, mStateLock was taken to
keep the current state still during the transaction. This left a small
window open, where a layer could be removed after the transaction flags
were checked but before the transaction was started holding the lock.
In that situation eTraversalNeeded would be set but only seen during the
next transaction cycle; however, because we're handling this transaction
(because of another flag) it will be commited, "loosing" the information
about the layer being removed -- so when the next transaction cycle due
to eTraversalNeeded starts, it won't notice that layers have been removed
and won't populated the ditchedLayers array.

Bug: 4483049

Change-Id: Ibb5989312f871339928ee1aa3f9567770d72969b
services/surfaceflinger/SurfaceFlinger.cpp
services/surfaceflinger/SurfaceFlinger.h