Change _connectAndLazySemaphoreInitLock to a SemaphoreSlim and use it in ConnectAsync.
Rename it to _connectLock and only use it for connecting. Replace its other usages (on SessionSemaphore and NextChannelNumber) with Interlocked operations.
Remove AuthenticationConnection semaphore. This static member placed a process-wide limit on the number of connections an application can make. I agree with the argument in https://github.com/sshnet/SSH.NET/issues/409#issuecomment-457415542 (and in several other issues/PRs) that this should not be something that the library attempts to control.
The last change broke a few tests which do things like making 100 connections (exceeding OpenSSH MaxStartups value). I was tempted to delete these tests as I don't think they have much value, but instead I just limited their concurrency.
The last change broke a few tests which do things like making 100 connections (exceeding OpenSSH MaxStartups value). I was tempted to delete these tests as I don't think they have much value, but instead I just limited their concurrency.
Best viewed with "Hide whitespace"