Skip to content

Main loop: rework timer logic#1308

Merged
zappolowski merged 1 commit intodunst-project:masterfrom
tobast:tobast/timer_logic
Apr 14, 2024
Merged

Main loop: rework timer logic#1308
zappolowski merged 1 commit intodunst-project:masterfrom
tobast:tobast/timer_logic

Conversation

@tobast
Copy link
Copy Markdown
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
Copy Markdown
Contributor

bynect commented Mar 13, 2024

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

@bynect bynect requested review from fwsmit and zappolowski March 13, 2024 10:49
@fwsmit
Copy link
Copy Markdown
Member

fwsmit commented Mar 15, 2024

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

@bynect
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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.
@tobast tobast force-pushed the tobast/timer_logic branch from 8baa6f3 to 5702095 Compare April 10, 2024 11:45
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

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

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

Files with missing lines 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
@bynect
Copy link
Copy Markdown
Contributor

bynect commented Apr 15, 2024

Thanks @tobast

@tobast
Copy link
Copy Markdown
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