Skip to content

Close socket on failure - #1822

Closed
YoavCohen wants to merge 2 commits into
paramiko:mainfrom
YoavCohen:close_socket_on_failure
Closed

YoavCohen wants to merge 2 commits into
paramiko:mainfrom
YoavCohen:close_socket_on_failure

Conversation

@YoavCohen

Copy link
Copy Markdown

As mentioned in socket docs:
"Sockets are automatically closed when they are garbage-collected, but it is recommended to close() them explicitly, or to use a with statement around them."

Resolve #1126

yoav added 2 commits March 4, 2021 10:44
As mentioned in socket docs:
"Sockets are automatically closed when they are garbage-collected, but it is recommended to close() them explicitly, or to use a with statement around them."

Resolve paramiko#1126
@MrMino

MrMino commented Mar 4, 2021

Copy link
Copy Markdown
Contributor

Does every socket.error signify a failure that would require socket.close()? Were custom sockets taken into consideration?

@YoavCohen

YoavCohen commented Mar 4, 2021 •

Copy link
Copy Markdown
Author

Does every socket.error signify a failure that would require socket.close()? Were custom sockets taken into consideration?

all this code runs under a condition the sock wasn't provided, so it muse be a socket created by connect function we are responsible for cleanup.

The scenario I encounter was when when errno=EHOSTUNREACH but sock.close() looks enough safe to call on any socket.error.
thoughts?

@dominiclondon

Copy link
Copy Markdown

What's the status of this?

@bskinn

bskinn commented Jun 1, 2022

Copy link
Copy Markdown
Contributor

@dominiclondon It's been idle, with other paramiko/fabric/invoke matters taking higher priority in bitprophet's weekly OSS allotment. Thanks for bumping it to indicate your interest in it, I've now triaged it.

@bskinn

bskinn commented Jun 1, 2022 •

Copy link
Copy Markdown
Contributor

May partially address #1127, per #1126 (comment).

#1127 (comment) also references #964 and #949.

Significant discussion in #949; #891 mentioned in passing, with appreciable discussion around #44, #952 (2017 era). #964 (comment) (also 2017) cross-references #367 #440 #441.

#964 (comment) (2019 era) suggests some other changes within/without(?) paramiko may have (partly?) helped the problem.

@bitprophet

bitprophet commented Jun 3, 2022 •

Copy link
Copy Markdown
Member

Thanks all. Merged this and wrote a quick test for it (😩). Does look like a lot of the other related tickets @bskinn dug up (👍🏻✨) aren't completely solved by this, but it'll still help with a subset for sure. Closed the one other that seemed like a full-on duplicate. Cherry picked to 2.8 and up, in case any of those get more bugfix releases.

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.

Unclosed socket on connection failure

5 participants