From: Luke Lau Date: Wed, 2 Sep 2020 17:29:11 +0000 (+0100) Subject: Tidy up rebase X-Git-Tag: 0.13.0.0~7^2~13 X-Git-Url: https://git.lukelau.me/?p=lsp-test.git;a=commitdiff_plain;h=6fa77d1acd9f1c76383ac179b36bacd9d22f2819 Tidy up rebase --- diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 2f99b19..430ac5b 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -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 diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index a6474bb..b98dca8 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -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