Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 7fb7187d authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

EventHub: Reimplement sysfsNodeChanged

There were several bugs in the old implementation of sysfsNodeChanged.
There are unfortunately no existing unit tests for EventHub, so the old
code and the new code are not tested exhaustively.

Issues addressed:
- The old code would concurrently modify mOpeningDevices while iterating
  through it, making the code difficult to reason about, particularly
  since calling openDeviceLocked() from the iteration would add an
  additional opening device.
- The old code was improperly erasing items from mOpeningDevices.
  vector::erase() returns the next iterator position after the removal,
  and when progressing to the next for loop iteration, the iterator is
  incremented again, leading to a missed element.
- Each call to isChanged() involves several syscalls, and the old code
  would perform the check multiple times on the same AssociatedDevice
  object. Note that for each changed sysfs node, the sysfs node is
  reloaded yet again for each openDeviceLocked() call, which this CL
  does not address.

Bug: 245989146
Test: atest SonyDualshock4BluetoothTest --iterations
Test: Presubmit
Flag: EXEMPT refactor/bug fix
Change-Id: Iaec9079d8c888310f6d8e496b9dd9df231aff228
parent e136587f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment