diff options
author | 2021-05-01 23:14:04 +0000 | |
---|---|---|
committer | 2021-05-07 00:20:20 -0700 | |
commit | ae02a1f49c1b0ae49af4331be1117b37616c0adb (patch) | |
tree | 09f6dc17c663dc36065f18edfff1364cd268d02d /libs/gui/SurfaceControl.cpp | |
parent | 96e84d982fc1e50998983bed031a005140fb0355 (diff) |
Store connections by token instead of by fd
The connections are currently stored by fd. If a connection is removed
via 'removeInputChannel', it is possible to re-create the same
connection and have it keyed by the same fd. When this happens, a race
condition may occur where a socket hangup on this fd would cause the
removal of a newly registered connection.
In this refactor, the connections are no longer stored by fd. The looper
interface for adding fds has two versions:
1) the old one that we are currently using, which is marked as 'do not
use'
2) the new one where a callback object is provided instead.
In this CL, we switch to the new version of the callback.
There is now also no need to store the inputchannels in a separate
structure, because we can use the connections collection that's now
keyed by token to find them.
In a future refactor, we should switch to using 'unique_ptr' for the
inputchannels. Most of the time when we are looking for an input
channel, we are actually interested in finding the corresponding
connection.
If we switch Connection to shared_ptr, we can also look into switching
LooperEventCallback to store a weak pointer to a connection instead of
storing the connection token. This should speed up the handling of
events, by avoiding a map lookup.
Test: ./reinitinput.sh. Observe that it doesnt finish after this patch
Test: atest inputflinger_tests
Bug: 182478748
Change-Id: I601f765eebfadcaeff3661a10a10c4a4f0477389
Diffstat (limited to 'libs/gui/SurfaceControl.cpp')
0 files changed, 0 insertions, 0 deletions