Skip to content

lib: make foreach_res() reload-safe#1279

Merged
pstorz merged 9 commits intobareos:masterfrom
arogge:dev/arogge/master/config-races
Nov 4, 2022
Merged

lib: make foreach_res() reload-safe#1279
pstorz merged 9 commits intobareos:masterfrom
arogge:dev/arogge/master/config-races

Conversation

@arogge
Copy link
Member

@arogge arogge commented Oct 17, 2022

Keep a reference to the config while looping over configuration resources with foreach_res().

The PR also removes uses of the GCC extension typeof() which are mostly not needed anymore and can be replaced with decltype() where still required.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Is the PR title usable as CHANGELOG entry?
  • Separate commit for CHANGELOG.md ("update CHANGELOG.md"). The PR number is correct.
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@arogge arogge marked this pull request as draft October 17, 2022 08:48
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Maybe we will get unused variabe warnings for the _config_table_.

@arogge arogge force-pushed the dev/arogge/master/config-races branch from 73d64ae to 4db5010 Compare November 2, 2022 14:09
@pstorz pstorz force-pushed the dev/arogge/master/config-races branch from 4db5010 to 498f9f1 Compare November 2, 2022 18:34
@pstorz pstorz marked this pull request as ready for review November 3, 2022 16:26
The new test does a foreach_res while another thread reloads the
configuration again and again.
This patch extends the foreach_res() macro so that the loop will
survive a configuration reload.
With alist being a cleanly typed template, we can omit all the type
casts in foreach_alist() and have it type safe.
This produces some issues with the existing usages which are also fixed.
Turn the old C-style cast using typeof() into a modern C++ static_cast
using decltype().
@pstorz pstorz force-pushed the dev/arogge/master/config-races branch from 498f9f1 to e3291d6 Compare November 3, 2022 16:28
@pstorz pstorz changed the title make foreach_res() reload-safe core: make foreach_res() reload-safe Nov 4, 2022
@pstorz pstorz changed the title core: make foreach_res() reload-safe lib: make foreach_res() reload-safe Nov 4, 2022
@pstorz pstorz self-requested a review November 4, 2022 10:39
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I only applied the check-sources changes.

@pstorz pstorz merged commit cda7bdc into bareos:master Nov 4, 2022
@pstorz pstorz mentioned this pull request Nov 4, 2022
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants