From 2f34f85e2f222c188e6032aa0d104952bee31ecb Mon Sep 17 00:00:00 2001 From: Frederik Vigen Date: Sat, 6 Jun 2020 20:51:19 +0200 Subject: [PATCH] Added fix to recvAll that doesn't use signal (Left 0) but the size of the buffer --- libs/network/Network/Socket.idr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/network/Network/Socket.idr b/libs/network/Network/Socket.idr index 485bee096..e7ebf26e0 100644 --- a/libs/network/Network/Socket.idr +++ b/libs/network/Network/Socket.idr @@ -173,10 +173,10 @@ recvAll sock = recvRec sock [] 64 recvRec : Socket -> List String -> ByteLength -> IO (Either SocketError String) recvRec sock acc n = do res <- recv sock n case res of - Left 0 => pure (Right $ concat $ reverse acc) Left c => pure (Left c) - Right (str, _) => let n' = min (n * 2) 65536 in - recvRec sock (str :: acc) n' + Right (str, res) => let n' = min (n * 2) 65536 in + if res < n then pure (Right $ concat $ reverse $ str :: acc) + else recvRec sock (str :: acc) n' ||| Send a message. |||