fix socket backend to stop looping when not receiving data

a endless loop would occur when empty of data is received
This commit is contained in:
Vincent Hanquez 2014-03-23 10:55:03 +00:00
parent 619d05f80f
commit beb4e7c67d

View file

@ -50,7 +50,9 @@ instance HasBackend Socket where
where loop 0 = return []
loop left = do
r <- Socket.recv sock left
liftM (r:) (loop (left - B.length r))
if B.null r
then return []
else liftM (r:) (loop (left - B.length r))
instance HasBackend Handle where
initializeBackend handle = hSetBuffering handle NoBuffering