Skip to content

Commit 47cfb79

Browse files
authored
Merge pull request #203
Skip waiting for the first connection to the key
2 parents ec503f2 + 5a53d2d commit 47cfb79

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ private void WaitForReclaimTimeout(Transport newTransport)
154154
? TimeSpan.FromMilliseconds(100)
155155
: TimeSpan.FromSeconds(3.01);
156156

157-
// We're only affected by the reclaim timeout if we're switching USB transports.
158-
if (_device.LastActiveTransport == newTransport)
157+
// Skip waiting if the transport is already active or was previously None
158+
if (_device.LastActiveTransport == newTransport || _device.LastActiveTransport == Transport.None)
159159
{
160160
_log.LogDebug(
161161
"{Transport} transport is already active. No need to wait for reclaim.",
162162
_device.LastActiveTransport);
163-
163+
_device.LastActiveTransport = newTransport;
164164
return;
165165
}
166166

Yubico.YubiKey/tests/integration/Yubico/YubiKey/ReclaimTimeoutTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public void SwitchingBetweenTransports_ForcesThreeSecondWait()
9393
sw3.Stop();
9494

9595
const long expectedLapse = 3000;
96-
Assert.True(sw1.ElapsedMilliseconds > expectedLapse);
96+
const long firstConnectionMaxTime = 100;
97+
Assert.True(sw1.ElapsedMilliseconds < firstConnectionMaxTime);
9798
Assert.True(sw2.ElapsedMilliseconds > expectedLapse);
9899
Assert.True(sw3.ElapsedMilliseconds > expectedLapse);
99100
}

0 commit comments

Comments
 (0)