Fix TestService shutdown (dotnet/corefx#27028)
authorDan Moseley <danmose@microsoft.com>
Sun, 11 Feb 2018 03:13:07 +0000 (19:13 -0800)
committerGitHub <noreply@github.com>
Sun, 11 Feb 2018 03:13:07 +0000 (19:13 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/2af251c3c083817975d76d659069400d98073965

src/libraries/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/TestService.cs

index 49d242d..03909e3 100644 (file)
@@ -92,10 +92,10 @@ namespace System.ServiceProcess.Tests
 
         private async Task WriteStreamAsync(PipeMessageByteCode code, int command = 0)
         {
-            const int writeTimeout = 60000;
             Task writeCompleted;
             if (_waitClientConnect.IsCompleted)
             {
+                const int writeTimeout = 60000;
                 if (code == PipeMessageByteCode.OnCustomCommand)
                 {
                     writeCompleted = _serverStream.WriteAsync(new byte[] { (byte)command }, 0, 1);
@@ -109,7 +109,8 @@ namespace System.ServiceProcess.Tests
             }
             else
             {
-                throw new TimeoutException($"Client didn't connect to the pipe");
+                // We get here if the service is getting torn down before a client ever connected;
+                // some tests do this.
             }
         }