Merge pull request 'catch *any* exception' (#3) from crashfix into dev

Reviewed-on: https://codeberg.org/jlamothe/gemcap/pulls/3
This commit is contained in:
Jonathan Lamothe 2023-01-04 15:02:01 +00:00
commit 115dcf3998
2 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,5 @@
# Changelog for gemcap
## Unreleased changes
- fixed a bug that would cause the server to crash when the client aborted the handshake by rejecting the key

View File

@ -31,7 +31,7 @@ module Network.Gemini.Capsule (
) where
import Control.Concurrent (forkIO)
import Control.Exception (IOException, try)
import Control.Exception (SomeException, try)
import Control.Exception.Base (bracket, finally)
import Control.Monad (void)
import qualified Data.Connection as C
@ -72,7 +72,7 @@ listenLoop sock params handler = do
certRef <- newIORef Nothing
let params' = adjustServerParams certRef params
try (accept params' sock) >>= \case
Left (_::IOException) -> return ()
Left (_::SomeException) -> return ()
Right conn -> void $ forkIO $ finally
(readIORef certRef >>= runConnection conn handler)
(C.close conn)