File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -140,15 +140,14 @@ cdef class Session:
140140 return handle_error_codes(rc, self ._session)
141141
142142 def disconnect (self ):
143- """ No-op. Handled by object de-allocation."""
144- # Due to bug in libssh that segfaults if session
145- # is disconnected before freeing channels spawned
146- # by that session - even if channels are closed.
147- pass
148- # if not c_ssh.ssh_is_connected(self._session):
149- # return
150- # with nogil:
151- # c_ssh.ssh_disconnect(self._session)
143+ """
144+ Cleanly disconnect connection. All channels left open at this point are invalidated.
145+ Interacting with their Channel objects will trigger UB.
146+ """
147+ if not c_ssh.ssh_is_connected(self ._session):
148+ return
149+ with nogil:
150+ c_ssh.ssh_disconnect(self ._session)
152151
153152 def connector_new (self ):
154153 cdef c_ssh.ssh_connector _connector
You can’t perform that action at this time.
0 commit comments