dedup backend: Fix leaking filedescriptor#2548
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughWrap raw directory file descriptors in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/src/stored/backends/dedupable/volume.cc (1)
180-187: Minor inconsistency: use!dird.ok()for consistency with other checks.Line 182 uses
dird.fileno() < 0while all other validity checks in this file use theok()method (e.g., lines 191, 275, 468, 480, etc.).Suggested fix for consistency
dird = open(path, dir_flags); - if (dird.fileno() < 0) { + if (!dird.ok()) { std::string errctx = "Cannot open '"; errctx += path; errctx += "'";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/src/stored/backends/dedupable/volume.cc` around lines 180 - 187, The check after opening the directory uses dird.fileno() < 0 which is inconsistent with other validity checks in this file; change the condition to use !dird.ok() (i.e., if (!dird.ok())) when testing the result of open(path, dir_flags) so it matches the style used elsewhere (see dird, open(path, dir_flags), dird.fileno(), dird.ok()); keep the existing error construction and throw behavior intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@core/src/stored/backends/dedupable/volume.cc`:
- Around line 180-187: The check after opening the directory uses dird.fileno()
< 0 which is inconsistent with other validity checks in this file; change the
condition to use !dird.ok() (i.e., if (!dird.ok())) when testing the result of
open(path, dir_flags) so it matches the style used elsewhere (see dird,
open(path, dir_flags), dird.fileno(), dird.ok()); keep the existing error
construction and throw behavior intact.
aa4b444 to
730f04b
Compare
pstorz
left a comment
There was a problem hiding this comment.
Looks good, please see my comment and let's sync about that.
ece401b to
f1713de
Compare
pstorz
left a comment
There was a problem hiding this comment.
Looks good! Only the backports are pending now.
This makes it clear that you closing the filedescriptor is already taken care of and reduces suprises.
efbf05c to
b0704c6
Compare
Thank you for contributing to the Bareos Project!
Please check
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)
Make sure you check/merge the PR using
devtools/pr-toolto have some simple automated checks run and a proper changelog record added.General
Source code quality