Skip to content

Race condition when both server and client disconnect #80

@drieseng

Description

@drieseng

When a server sends a SSH_MSG_DISCONNECT and the client invokes Disconnect() or Dispose() at the same time, this can lead to one of following exceptions (from issue #58):

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.get_Available()
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection() at System.Net.Sockets.Socket.get_Available()
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection()

or

System.NullReferenceException: Object reference not set to an instance of an object.
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection() at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions