Skip to content

Add back-reference from Transport to the SSHClient that created it - #891

Closed
omeranson wants to merge 1 commit into
paramiko:masterfrom
omeranson:sshclient_reference
Closed

omeranson wants to merge 1 commit into
paramiko:masterfrom
omeranson:sshclient_reference

Conversation

@omeranson

Copy link
Copy Markdown
Contributor

In some cases, the SSH client is created, the command is executed, the
streams are extracted, and the explicit reference to SSHClient is then
discarded (since it was e.g. created in a function that only returns the
streams). In this case, the SHSClient may be garbage collected, and the
connection's state is undefined.

This fix adds a reference from Transport to the SSHClient that created
it. The streams have a reference to the Channel, which references the
Transport. Now that the Transport references the SSHClient, it won't be
garbage collected until it is closed.

Closes-Bug: #44
Related-Bug: #344

In some cases, the SSH client is created, the command is executed, the
streams are extracted, and the explicit reference to SSHClient is then
discarded (since it was e.g. created in a function that only returns the
streams). In this case, the SHSClient may be garbage collected, and the
connection's state is undefined.

This fix adds a reference from Transport to the SSHClient that created
it. The streams have a reference to the Channel, which references the
Transport. Now that the Transport references the SSHClient, it won't be
garbage collected until it is closed.

Closes-Bug: paramiko#44
Related-Bug: paramiko#344
@coveralls

coveralls commented Feb 9, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 74.281% when pulling a3b9c6c on omeranson:sshclient_reference into d35b67a on paramiko:master.

@omeranson

Copy link
Copy Markdown
Contributor Author

Hi, @bitprophet , I'd be happy if you could take a look.

Thanks.

@bitprophet

Copy link
Copy Markdown
Member

Can't help but think this is a code smell implying that Client and Transport need some shaking up, but I'm not about to demand that for such an old codebase 😆 thanks for the patch!

@bitprophet bitprophet added this to the 1.17.4 etc milestone Feb 19, 2017
bitprophet added a commit that referenced this pull request Feb 20, 2017
@bitprophet

Copy link
Copy Markdown
Member

Cherry-picked back to 1.17.x on up. Thanks!

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.

3 participants