Wait for reads to finish before reading the result

As requested by @dom96, this fixes an issue seen here: https://github.com/nim-lang/redis/pull/4#issuecomment-312713921
This commit is contained in:
Euan T
2017-07-03 20:13:25 +01:00
committed by GitHub
parent 9e12db4459
commit a5681d03e3

View File

@@ -534,14 +534,14 @@ proc recvLineInto*(socket: AsyncSocket, resString: FutureVar[string],
var c = ""
while true:
let recvFut = recv(socket, 1, flags)
c = recvFut.read()
c = await recvFut
if c.len == 0:
resString.mget.setLen(0)
resString.complete()
return
if c == "\r":
let recvFut = recv(socket, 1, flags) # Skip \L
c = recvFut.read()
c = await recvFut
assert c == "\L"
addNLIfEmpty()
resString.complete()