Compare commits

...

3 Commits

Author SHA1 Message Date
Jonathan Lamothe 77cfcce5df version 0.1.0.1 2023-01-04 10:09:48 -05:00
Jonathan Lamothe 115dcf3998 Merge pull request 'catch *any* exception' (#3) from crashfix into dev
Reviewed-on: https://codeberg.org/jlamothe/gemcap/pulls/3
2023-01-04 15:02:01 +00:00
Jonathan Lamothe 554efdabcb 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.
2023-01-01 11:52:59 -05:00
4 changed files with 8 additions and 5 deletions

View File

@ -1,3 +1,6 @@
# Changelog for gemcap # Changelog for gemcap
## Unreleased changes ## 0.1.0.1
- updated underlying libraries to more current versions
- fixed a bug that would cause the server to crash when the client aborted the handshake by rejecting the key

View File

@ -5,7 +5,7 @@ cabal-version: 2.2
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: gemcap name: gemcap
version: 0.1.0 version: 0.1.0.1
synopsis: a simple Gemini capsule (server) synopsis: a simple Gemini capsule (server)
description: a simple Gemini capsule (server) - see README.md for details description: a simple Gemini capsule (server) - see README.md for details
category: Gemini category: Gemini

View File

@ -1,5 +1,5 @@
name: gemcap name: gemcap
version: 0.1.0 version: 0.1.0.1
license: AGPL-3.0-or-later license: AGPL-3.0-or-later
author: "Jonathan Lamothe" author: "Jonathan Lamothe"
maintainer: "jonathan@jlamothe.net" maintainer: "jonathan@jlamothe.net"

View File

@ -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)