@@ -353,26 +353,26 @@ public void BypassMongocryptdClientWhenSharedLibraryTest(
353
353
try
354
354
{
355
355
tcpListener = new TcpListener ( mongocryptdIpAddress , port : mongocryptPort ) ;
356
- var listenerThread = new Thread ( new ParameterizedThreadStart ( ThreadStart ) ) { IsBackground = true } ;
356
+ tcpListener . Start ( ) ;
357
+ var listenerThread = new Thread ( ThreadStart ) { IsBackground = true } ;
358
+ listenerThread . Start ( tcpListener ) ;
357
359
358
360
using ( var clientEncrypted = ConfigureClientEncrypted ( kmsProviderFilter : "local" , extraOptions : extraOptions ) )
359
361
{
360
362
var coll = GetCollection ( clientEncrypted , __collCollectionNamespace ) ;
361
363
362
- listenerThread . Start ( tcpListener ) ;
363
-
364
364
_ = Record . Exception ( ( ) => Insert ( coll , async , new BsonDocument ( "unencrypted", "test") ) ) ;
365
+ }
365
366
366
- if ( listenerThread . Join ( timeout ) )
367
- {
368
- // This exception is never thrown when mognocryptd mongoClient is not spawned which is expected behavior.
369
- // However, if we intentionally break that logic to spawn mongocryptd mongoClient regardless of shared library,
370
- // this exception sometimes won't be thrown. In all such cases the spent time in listenerThread.Join is higher
371
- // or really close to timeout. So it's unclear why Join doesn't throw in that cases, but that logic is unrelated
372
- // to the driver and csfle in particular. We rely on the fact that even if we break this logic,
373
- // we run this test more than once.
374
- throw new Exception ( $ "Listener accepted a tcp call for moncgocryptd during { timeout } .") ;
375
- }
367
+ if ( listenerThread . Join ( timeout ) )
368
+ {
369
+ // This exception is never thrown when mognocryptd mongoClient is not spawned which is expected behavior.
370
+ // However, if we intentionally break that logic to spawn mongocryptd mongoClient regardless of shared library,
371
+ // this exception sometimes won't be thrown. In all such cases the spent time in listenerThread.Join is higher
372
+ // or really close to timeout. So it's unclear why Join doesn't throw in that cases, but that logic is unrelated
373
+ // to the driver and csfle in particular. We rely on the fact that even if we break this logic,
374
+ // we run this test more than once.
375
+ throw new Exception ( $ "Listener accepted a tcp call for moncgocryptd during { timeout } .") ;
376
376
}
377
377
}
378
378
finally
@@ -385,7 +385,6 @@ void ThreadStart(object param)
385
385
try
386
386
{
387
387
var tcpListener = ( TcpListener ) param ;
388
- tcpListener . Start ( ) ;
389
388
using var client = tcpListener . AcceptTcpClient ( ) ;
390
389
// Perform a blocking call to accept requests.
391
390
// if we're here, then something queries port 27030.
0 commit comments