Skip to content

session dealloc  #55

Closed
Closed
@eliwe

Description

@eliwe

Hi,

I have an issue that originates from the usage of dealloc to close and release sessions.
The code in dealloc calls
c_ssh2.libssh2_session_disconnect(self._session, b"end") c_ssh2.libssh2_session_free(self._session)

In session disconnect a message is sent to the other side singling the disconnect. But by the time this function is called (dealloc is called at some point after the object is not used any more) the underlaying socket might have been closed and libssh2 will return and error . Worst yet is that the fileno gets reused for another connection and the message will be sent to a different peer (this happened to me).

I changed the API for session to include a release function. I also removed the free from channel as it shouldn't be called if the session has been release.
see:
https://github.com/eliwe/ssh2-python

I didn't send a pull request as its not a proper fix (it does solve my immediate problem).

I didn't write sample code to recreate the issue as its not 100 reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions