Skip to content
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

Main loop: rework timer logic #1308

Merged
merged 1 commit into from
Apr 14, 2024

Conversation

tobast
Copy link
Contributor

@tobast tobast commented Mar 8, 2024

This logic was over-complicated and caused multiple bugs. This hopefully remediates to this for good. Fixes #1196.

I finally took the time to look at the timer logic of the run function, check what was actually needed, and came up with this simplification. I tried to document it in the function, feedback welcome :)

This passes make test correctly:

$ make test
[…]
Total: 193 tests (84019 ticks, 0.084 sec), 2529 assertions
Pass: 193, fail: 0, skip: 0.

Issue #1196 is also fixed: I tried manually the scenarios I could think of (including the one mentioned in the issue) and could not get a Source ID xx was not found error.

Note for the future: replacing g_timeout_add with g_timeout_add_once would enhance robustness, in case a bug causes two timers to be running concurrently — which would double the number of invocations of run unnecessarily, until no notifications are shown for a time, and could exponentially blow-up if the bug occurs within the bug. However, this function was introduced in GLib 2.74, which is too recent for eg. Debian Bullseye.

@bynect
Copy link
Member

bynect commented Mar 13, 2024

Looks good to me. We have to wait for the ci to work again though

@fwsmit
Copy link
Member

fwsmit commented Mar 15, 2024

You could maybe use an #if to use the new glib function where available

@bynect
Copy link
Member

bynect commented Mar 15, 2024

You could maybe use an #if to use the new glib function where available

Wouldn't that be just redundant, given that currently this does the same thing?

@tobast
Copy link
Contributor Author

tobast commented Mar 15, 2024

In my opinion, using g_timeout_add_once adds a slight bit of robustness, but adding conditionals on the version of glib would decrease robustness -- eventually one of the branches of the preprocessor would be changed without the other being updated, etc., causing more opportunities for bugs than it remedies to.

@bynect
Copy link
Member

bynect commented Apr 9, 2024

Could you please rebase to master for the ci?

This logic was over-complicated and caused multiple bugs. This hopefully
remediates to this for good. Fixes dunst-project#1196.
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 65.64%. Comparing base (bd5b333) to head (5702095).
Report is 3 commits behind head on master.

Files Patch % Lines
src/dunst.c 0.00% 16 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1308      +/-   ##
==========================================
- Coverage   65.65%   65.64%   -0.01%     
==========================================
  Files          50       50              
  Lines        8051     8052       +1     
  Branches      928      925       -3     
==========================================
  Hits         5286     5286              
- Misses       2765     2766       +1     
Flag Coverage Δ
unittests 65.64% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zappolowski zappolowski merged commit 28947bf into dunst-project:master Apr 14, 2024
19 checks passed
@bynect
Copy link
Member

bynect commented Apr 15, 2024

Thanks @tobast

@tobast
Copy link
Contributor Author

tobast commented Apr 15, 2024

Whoops, sorry for not merging the review! I've been pretty busy…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

glib errors (CRITICAL: Source ID 16 was not found when attempting to remove it)
5 participants