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

Use Base.IOError more consistently for read/write operation failures #257

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Sep 15, 2022

Previously we might throw ArgumentError, MbedException, or AssertionError. This PR proposes we more closely follow Sockets stdlib behavior by making these errors Base.IOError for consistency.

Fixes #188

Previously we might throw ArgumentError, MbedException, or AssertionError.
This PR proposes we more closely follow Sockets stdlib behavior by making
these errors Base.IOError for consistency.

Fixes #188
@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #257 (e9fe500) into master (1cf08a2) will decrease coverage by 0.00%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #257      +/-   ##
==========================================
- Coverage   73.74%   73.73%   -0.01%     
==========================================
  Files          12       12              
  Lines         716      712       -4     
==========================================
- Hits          528      525       -3     
+ Misses        188      187       -1     
Impacted Files Coverage Δ
src/ssl.jl 72.53% <66.66%> (-0.04%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@quinnj quinnj merged commit 75f38e9 into master Sep 16, 2022
@quinnj quinnj deleted the jq/ioerror branch September 16, 2022 15:58
gustafsson added a commit to gustafsson/MbedTLS.jl that referenced this pull request Oct 18, 2022
Instead of MbedException, in line with JuliaLang#257

Fixes JuliaLang#259
@@ -372,8 +361,7 @@ function ssl_unsafe_read(ctx::SSLContext, buf::Ptr{UInt8}, nbytes::UInt)
ctx.bytesavailable = 0 ;@😬 "ssl_read ⌛️ $nread"
return nread
elseif n < 0
ssl_abandon(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was it intentional to drop the call to ssl_abandon here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmm, good question. I think the original intent was just to throw an IOError instead of an MbedException, but we perhaps want the other cleanup that happens in ssl_abandon, so maybe it would be better if we changed ssl_abandon to just throw the IOError instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cleanup sounds like the right thing to do. I guess the scenario where it would make any difference would be to give a more clear error message were someone to catch the IO-error and then try to read or write again?

I wouldn't expect ssl_abandon to throw though. It would make it harder for me to reason about the control flow in ssl_unsafe_read.

A helper like throw(mbed_ioerr(n)) could come in handy after calling ssl_abandon.

Copy link
Contributor

Choose a reason for hiding this comment

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

quinnj pushed a commit that referenced this pull request Oct 21, 2022
Instead of MbedException, in line with #257

Fixes #259
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.

ssl_unsafe_read requires isreadable(::SSLContext)
2 participants