Guard device adding and removing with mutex #513
+8
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks like Udev might retrigger device adding on enumeration phase which causes addDevice() to be called twice on the same device at the same time or too fast.
Adding a mutex to prevent this, so
DeviceManager::addDevice() is not
ran concurrently.
Here are some logs from
journalctlBefore changes:
When restarting the service, all OK
When adding more logs, I see _addHandler() called twice, and keeps repeating on same timestamp
After adding the mutex, it seem to fix the issue
I'm unsure if this issue is related to
gnome-shelldoing its own initialization, but definitely it looks like syncronization issue between services. Too many are trying to talk to the same device when its found.This potentially fixes or affects following issues:
there were many others that mention "on boot", "restart", "delay" and "MX Master 3".
Maybe something else needs also be done for "Device added X", "Device removed X", so that it won't retrigger so fast.
However, this fixes my issue, I hope it helps others.