Tidy up rebase
authorLuke Lau <luke_lau@icloud.com>
Wed, 2 Sep 2020 17:29:11 +0000 (18:29 +0100)
committerLuke Lau <luke_lau@icloud.com>
Fri, 9 Oct 2020 12:56:54 +0000 (13:56 +0100)
src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Session.hs

index 2f99b19c54c26675edac9f6a874b8b404dbf32e1..430ac5b9153df91469590b6f772b14b2aaf6ccc9 100644 (file)
@@ -230,7 +230,7 @@ runSessionWithHandles' serverProc serverIn serverOut config' caps rootDir sessio
   where
   -- | Asks the server to shutdown and exit politely
   exitServer :: Session ()
-  exitServer = request_ SShutdown (Nothing :: Maybe Value) >> sendNotification SExit Empty
+  exitServer = request_ SShutdown Empty >> sendNotification SExit Empty
 
   -- | Listens to the server output until the shutdown ack,
   -- makes sure it matches the record and signals any semaphores
index a6474bb2ca1b0b9b9bd0964960c5a4670c48cadb..b98dca84f975ccfd10035b27a43476e969090002 100644 (file)
@@ -269,21 +269,18 @@ runSession' serverIn serverOut mServerProc serverHandler config caps rootDir exi
       errorHandler = throwTo mainThreadId :: SessionException -> IO ()
       serverListenerLauncher =
         forkIO $ catch (serverHandler serverOut context) errorHandler
-      server = (Just serverIn, Just serverOut, Nothing, serverProc)
       msgTimeoutMs = messageTimeout config * 10^6
       serverAndListenerFinalizer tid = do
         let cleanup
-              | Just sp <- mServerProc = cleanupProcess (Just serverIn, Just serverOut, Nothing, sp)
+              | Just sp <- mServerProc = do
+                  -- Give the server some time to exit cleanly
+                  timeout msgTimeoutMs (waitForProcess sp)
+                  cleanupProcess (Just serverIn, Just serverOut, Nothing, sp)
               | otherwise = pure ()
-        finally (timeout msgTimeoutMs (runSession' exitServer)) $ do
+        finally (timeout msgTimeoutMs (runSession' exitServer))
                 -- Make sure to kill the listener first, before closing
                 -- handles etc via cleanupProcess
-                killThread tid
-                -- Give the server some time to exit cleanly
-#ifndef mingw32_HOST_OS
-                timeout msgTimeoutMs (waitForProcess serverProc)
-#endif
-                cleanup
+                (killThread tid >> cleanup)
 
   (result, _) <- bracket serverListenerLauncher
                          serverAndListenerFinalizer