Fix crash on empty write (#930)
This commit is contained in:
parent
74c402ed9d
commit
1721f078c7
|
@ -129,7 +129,9 @@ method write*(s: ChronosStream, msg: seq[byte]): Future[void] =
|
|||
# drives up memory usage
|
||||
if msg.len == 0:
|
||||
trace "Empty byte seq, nothing to write"
|
||||
return
|
||||
let fut = newFuture[void]("chronosstream.write.empty")
|
||||
fut.complete()
|
||||
return fut
|
||||
if s.closed:
|
||||
let fut = newFuture[void]("chronosstream.write.closed")
|
||||
fut.fail(newLPStreamClosedError())
|
||||
|
|
|
@ -150,6 +150,7 @@ template commonTransportTest*(prov: TransportProvider, ma1: string, ma2: string
|
|||
proc acceptHandler() {.async, gcsafe.} =
|
||||
while true:
|
||||
let conn = await transport1.accept()
|
||||
await conn.write(newSeq[byte](0))
|
||||
await conn.write("Hello!")
|
||||
await conn.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue