Go to file
Jeff Brown 0cacb87f02 Fix possible race conditions during channel unregistration.
Previously, the input dispatcher assumed that the input channel's
receive pipe file descriptor was a sufficiently unique identifier for
looking up input channels in its various tables.  However, it can happen
that an input channel is disposed and then a new input channel is
immediately created that reuses the same file descriptor.  Ordinarily
this is not a problem, however there is a small opportunity for a race
to arise in InputQueue.

When InputQueue receives an input event from the dispatcher, it
generates a finishedToken that encodes the channel's receive pipe fd,
and a sequence number.  The finishedToken is used by the ViewRoot
as a handle for the event so that it can tell the InputQueue when
the event has finished being processed.

Here is the race:

1. InputQueue receives an input event, assigns a new finishedToken.
2. ViewRoot begins processing the input event.
3. During processing, ViewRoot unregisters the InputChannel.
4. A new InputChannel is created and is registered with the Input Queue.
   This InputChannel happens to have the same receive pipe fd as
   the one previously registered.
5. ViewRoot tells the InputQueue that it has finished processing the
   input event, passing along the original finishedToken.
6. InputQueue throws an exception because the finishedToken's receive
   pipe fd is registered but the sequence number is incorrect so it
   assumes that the client has called finish spuriously.

The fix is to include a unique connection id within the finishedToken so
that the InputQueue can accurately confirm that the token belongs to
the currently registered InputChannel rather than to an old one that
happened to have the same receive pipe fd.  When it notices this, it
ignores the spurious finish.

I've also made a couple of other small changes to avoid similar races
elsewhere.

This patch set also includes a fix to synthesize a finished signal
when the input channel is unregistered on the client side to
help keep the server and client in sync.

Bug: 2834068
Change-Id: I1de34a36249ab74c359c2c67a57e333543400f7b
2010-08-17 17:03:42 -07:00
awt Add correct copyright headers to multiple files 2010-03-11 18:22:10 -08:00
cmds added BinderService<> template to help creating native binder services 2010-07-14 18:43:19 -07:00
include Fix possible race conditions during channel unregistration. 2010-08-17 17:03:42 -07:00
libs Fix possible race conditions during channel unregistration. 2010-08-17 17:03:42 -07:00
opengl fix [2912927] Can't get NV_draw_path extension to work 2010-08-13 14:17:58 -07:00
services/surfaceflinger Merge "fix a typo that prevented glTexImage2D codepath to work" into gingerbread 2010-08-13 16:29:48 -07:00
vpn
MODULE_LICENSE_APACHE2
NOTICE Adding PacketVideo attribution in NOTICE. 2010-05-06 14:15:47 -07:00