OSDN Git Service

fix a race condition in undoDequeue(), where 'tail' could be computed incorrectly.
authorMathias Agopian <mathias@google.com>
Tue, 27 Apr 2010 23:11:38 +0000 (16:11 -0700)
committerMathias Agopian <mathias@google.com>
Wed, 28 Apr 2010 23:12:54 +0000 (16:12 -0700)
commit0a8cd0689a76dbca7405004caac4dde4c0250aea
tree0b2f90c41d20b3f49027b245950429392f9942bd
parentfd4a2323743f7f4398efc6b8ca48e6242c149c91
fix a race condition in undoDequeue(), where 'tail' could be computed incorrectly.

in the undoDequeue() case, 'tail' was recalculated from 'available' and 'head'
however there was a race between this and retireAndLock(), which could cause
'tail' to be recalculated wrongly.

the interesting thing though is that retireAndLock() shouldn't have any impact
on the value of 'tail', which is client-side only attribute.
we fix the race by saving the value of 'tail' before dequeue() and restore it
in the case of undoDequeue(), since we know it doesn't depend on retireAndLock().

Change-Id: I4bcc4d16b6bc4dd93717ee739c603040b18295a0
include/private/surfaceflinger/SharedBufferStack.h
libs/surfaceflinger_client/SharedBufferStack.cpp