-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
asyncnet: don't try to close the socket again [backport] #15174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO an exception should be raised if you try to close an already closed socket. Maybe you can raise an exception instead of doing nothing?
lib/pure/asyncnet.nim
Outdated
elif res != 1: | ||
raiseSSLError() | ||
socket.closed = true # TODO: Add extra debugging checks for this. | ||
if not socket.closed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer:
if socket.closed: return
Style rather than wrapping everything in more and more nested ifs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, nested ifs are better.
The closed flag isn't a good design by any means, but let's have this working first before I get rid of the flag and potentially create a non-backportable commit.
dcf8946
to
fecaa03
Compare
|
it always calls |
Nah, |
That sounds dangerous, but alright, in any case I would still match the semantics in |
Currently I'm not doing that because I'm not invalidating the socket. I can certainly do so, but IMO it's better to do that with the follow up refactoring to get rid of the |
The closed flag isn't a good design by any means, but let's have this working first before I get rid of the flag and potentially create a non-backportable commit. (cherry picked from commit 957bf15)
The closed flag isn't a good design by any means, but let's have this working first before I get rid of the flag and potentially create a non-backportable commit. (cherry picked from commit 957bf15)
The closed flag here doesn't seem to be a a good design to me, but until
I can understand why it was needed it seems unwise to just replace it
with the invalidation of the socket.
Fixes #9867 (comment)
/cc @dom96 as this
closed
flag was added by him. This flag appear to have survived the refactoring in 1661062, where its sisternet
module use the different approach of invalidating theSocket
instead of a flag.