* fix: make Disconnect safe to call concurrently
Connection.client was read and written without synchronization, so
calling Disconnect from another goroutine raced IsConnected and the
Exec methods, and could hand them a nil client.
The client is now held in an atomic.Value, which unlike a mutex keeps
Connection copyable for the types embedding it by value, and each method
loads it once.
Fixes #498
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
* fix: synchronize the transport state Disconnect clears
WinRM cleared its client and OpenSSH its connected flag without synchronization while commands read them, so those are now atomic and WinRM commands use the client they loaded. Connection keeps its client behind a shared, mutex guarded pointer instead of an atomic.Value, which must not be copied after first use either, and the concurrency test now disconnects deterministically between the connection check and the command.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
* test: race unordered reads against Disconnect
The ordered test only covers the nil-client interleaving. Also qualify Disconnect's doc: whether a running command is interrupted depends on the transport.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
---------
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>