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

RCORE-2242: Include pathname in exception thrown in File::rw_lock #8000

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Aug 27, 2024

What, How & Why?

Fixes #7999 #8007

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

@cla-bot cla-bot bot added the cla: yes label Aug 27, 2024
@jedelbo jedelbo requested a review from tgoyne August 27, 2024 14:00
Copy link

coveralls-official bot commented Aug 27, 2024

Pull Request Test Coverage Report for Build jorgen.edelbo_421

Details

  • 14 of 15 (93.33%) changed or added relevant lines in 2 files are covered.
  • 339 unchanged lines in 29 files lost coverage.
  • Overall coverage decreased (-0.02%) to 91.12%

Changes Missing Coverage Covered Lines Changed/Added Lines %
test/object-store/util/test_utils.cpp 3 4 75.0%
Files with Coverage Reduction New Missed Lines %
src/realm/array_backlink.cpp 1 91.38%
src/realm/array_mixed.cpp 1 94.02%
src/realm/sort_descriptor.cpp 1 94.06%
src/realm/util/serializer.cpp 1 90.43%
test/object-store/util/test_utils.cpp 1 59.82%
test/test_dictionary.cpp 1 99.83%
src/realm/array_blobs_big.cpp 2 98.58%
src/realm/list.cpp 2 87.37%
src/realm/index_string.hpp 3 93.48%
src/realm/sync/client.cpp 3 90.96%
Totals Coverage Status
Change from base Build 2586: -0.02%
Covered Lines: 217433
Relevant Lines: 238622

💛 - Coveralls

@@ -1152,6 +1152,11 @@ bool File::rw_lock(bool exclusive, bool non_blocking)
// or the OS will deadlock when un-suspending the app.
int mode = exclusive ? O_WRONLY | O_NONBLOCK : O_RDWR | O_NONBLOCK;

auto report_err = [path = m_fifo_path](int err, const char* msg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we worry about the cost of copying this string here?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any reason for this to not just capture [this].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -1152,6 +1152,11 @@ bool File::rw_lock(bool exclusive, bool non_blocking)
// or the OS will deadlock when un-suspending the app.
int mode = exclusive ? O_WRONLY | O_NONBLOCK : O_RDWR | O_NONBLOCK;

auto report_err = [path = m_fifo_path](int err, const char* msg) {
auto message = util::format("%1: %2, path = '%3'", msg, std::system_category().message(err), path);
throw RuntimeError(ErrorCodes::FileOperationFailed, message); // LCOV_EXCL_LINE
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we probably shouldn't worry about the cost of copying the string here, but should message be moved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think not. RuntimeError takes a std::string_view as parameter.

@jedelbo jedelbo requested a review from jbreams August 28, 2024 08:56
@jedelbo jedelbo requested a review from jbreams August 28, 2024 14:29
Copy link
Contributor

@jbreams jbreams left a comment

Choose a reason for hiding this comment

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

🚢 🇮🇹 when the tests all pass!

@jedelbo jedelbo merged commit a02402c into master Aug 29, 2024
45 checks passed
@jedelbo jedelbo deleted the je/rw-lock branch August 29, 2024 08:02
@github-actions github-actions bot mentioned this pull request Aug 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If File::rw_lock() fails to open a file the exception message does not contain the filename
3 participants