Commit f2327e76 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Copy of the rest of the buffer when receiving network data



Otherwise the whole ByteString with the message (that has been already
processed) is retained until more data is received, unnecessarily
occupying memory, possibly for long time periods.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent a2ab277c
......@@ -308,7 +308,9 @@ recvMsg s = do
if B.null ibuf -- if old buffer didn't contain a full message
-- then we read from network:
then recvUpdate (clientConfig s) (rsocket s) cbuf
else return (imsg, B.tail ibuf) -- else we return data from our buffer
-- else we return data from our buffer, copying it so that the whole
-- message isn't retained and can be garbage collected
else return (imsg, B.copy (B.tail ibuf))
writeIORef (rbuf s) nbuf
return $ UTF8.toString msg
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment