catch Error_EOF exception and return empty data.
This commit is contained in:
parent
beb4e7c67d
commit
8653d49a42
1 changed files with 8 additions and 3 deletions
|
@ -72,9 +72,14 @@ sendData ctx dataToSend = liftIO (checkValid ctx) >> mapM_ sendDataChunk (L.toCh
|
||||||
recvData :: MonadIO m => Context -> m B.ByteString
|
recvData :: MonadIO m => Context -> m B.ByteString
|
||||||
recvData ctx = liftIO $ do
|
recvData ctx = liftIO $ do
|
||||||
checkValid ctx
|
checkValid ctx
|
||||||
|
E.catchJust (\Error_EOF -> Just ())
|
||||||
|
doRecv
|
||||||
|
(\() -> return B.empty)
|
||||||
|
where doRecv = do
|
||||||
pkt <- withReadLock ctx $ recvPacket ctx
|
pkt <- withReadLock ctx $ recvPacket ctx
|
||||||
either onError process pkt
|
either onError process pkt
|
||||||
where onError err@(Error_Protocol (reason,fatal,desc)) =
|
|
||||||
|
onError err@(Error_Protocol (reason,fatal,desc)) =
|
||||||
terminate err (if fatal then AlertLevel_Fatal else AlertLevel_Warning) desc reason
|
terminate err (if fatal then AlertLevel_Fatal else AlertLevel_Warning) desc reason
|
||||||
onError err =
|
onError err =
|
||||||
terminate err AlertLevel_Fatal InternalError (show err)
|
terminate err AlertLevel_Fatal InternalError (show err)
|
||||||
|
|
Loading…
Reference in a new issue