-
-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfkill code refactoring #1015
rfkill code refactoring #1015
Conversation
Kernel 5.11 added one more field to the `struct rfkill_event` and broke unnecessarily strict check in `rfkill.cpp`. According to `linux/rfkill.h`, we must accept events at least as large as v1 event size and should be prepared to get additional fields at the end of a v1 event structure.
Open rfkill device only once per module. Remove rfkill threads and use `Glib::signal_io` as a more efficient way to poll the rfkill device. Handle runtime errors from rfkill and stop polling of the device instead of crashing waybar.
The string was always overwritten in `update()`; don't need to store temporary value in the class.
The timer thread was always reading the same value from Rfkill state.
Moving rfkill to the main event loop had unexpected side-effects. Notably, the network module mutex can block all the main thread events for several seconds while the network worker thread is sleeping. Instead of waiting for the mutex let's hope that the worker thread succeeds and schedule timer thread wakeup just in case.
a383238
to
6d5afda
Compare
I haven't found time for a better look at the @rxguy, @pvalena, do you mind trying this PR? Only the first commit is required to resolve #994 and that's the only commit I'm planning to cherry-pick for Fedora package, but it'll be nice to test the rest of the changes here on another system. |
@alebastr Sure I'd try... can you build the package in COPR for rawhide? |
Just a small comment, otherwise LGTM, no suggestion for the network part, relying on the timer thread is a good idea. |
LGTM thanks Aleksei! |
I only wanted to fix that one event size check in
rfkill.cpp
. Should have more willpower to stop and ignore the rest 😭Summary:
Bluetooth::interval_thread_
was not doing anything useful because it had no way to get changed status value. Now we have 3 less threads 😄network.cpp
was beyond an evening coding exercise. Although I'm quite curious why we have to sleep for 5 seconds while holding the mutex and will check that on another evening.Fixes #994