Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Closed Unassigned: [Proposed Fix] Timeout waiting for KeyExchange with multi-threaded connections [1756]

$
0
0
I use renci.sshnet in a multi-threaded/multi-concurrent-connections environment. Some connections were experiencing a timeout during the connection initiation, causing the connection to fail. The timeout was occuring during the KeyExchange.

(Using Revision 28765)
Inspecting the code in the area of the timeout showed that a lock on the session object was being applied in Session.cs lines 438 through 581. Within these lines is a call to
```
WaitHandle(this._keyExchangeCompletedWaitHandle); //on line 538
```
The above timesout occurs because of the deadlock condition from the WaitHandle call that releases the thread of execution while holding a lock on the session object. The key exchange process' normal and subsequent call from within any of the various Security\KeyExchange_xxx_.cs modules
```
this.Session.MessageReceived += Session_MessageReceived; // cannot complete because of the lock in Session Connect
```
is blocked from completing until the WaitHandle eventually times out. But, by this time, the KeyExchange negotiation is over and failed and so the conneciton also fails.

The remedy that has been tested is to remove the end of scope of the lock (the close curly brace '}') from line 581 to line 536. This removes the deadlock and allows the key exchange to negotiate without blocking.
Comments: As mentioned in issue 1757:
Reporter cannot upgrade to latest version to see if issue is fixed.

Viewing all articles
Browse latest Browse all 1026

Trending Articles