catch *any* exception
`listenLoop` was crashing when the client closed the connection during the handshake. How this doesn't qualify as an `IOException` is beyond me.
This commit is contained in:
parent
a69a9385b6
commit
554efdabcb
|
@ -1,3 +1,5 @@
|
||||||
# Changelog for gemcap
|
# Changelog for gemcap
|
||||||
|
|
||||||
## Unreleased changes
|
## Unreleased changes
|
||||||
|
|
||||||
|
- fixed a bug that would cause the server to crash when the client aborted the handshake by rejecting the key
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Network.Gemini.Capsule (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Concurrent (forkIO)
|
import Control.Concurrent (forkIO)
|
||||||
import Control.Exception (IOException, try)
|
import Control.Exception (SomeException, try)
|
||||||
import Control.Exception.Base (bracket, finally)
|
import Control.Exception.Base (bracket, finally)
|
||||||
import Control.Monad (void)
|
import Control.Monad (void)
|
||||||
import qualified Data.Connection as C
|
import qualified Data.Connection as C
|
||||||
|
@ -72,7 +72,7 @@ listenLoop sock params handler = do
|
||||||
certRef <- newIORef Nothing
|
certRef <- newIORef Nothing
|
||||||
let params' = adjustServerParams certRef params
|
let params' = adjustServerParams certRef params
|
||||||
try (accept params' sock) >>= \case
|
try (accept params' sock) >>= \case
|
||||||
Left (_::IOException) -> return ()
|
Left (_::SomeException) -> return ()
|
||||||
Right conn -> void $ forkIO $ finally
|
Right conn -> void $ forkIO $ finally
|
||||||
(readIORef certRef >>= runConnection conn handler)
|
(readIORef certRef >>= runConnection conn handler)
|
||||||
(C.close conn)
|
(C.close conn)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user