mirror of https://github.com/vacp2p/nim-libp2p.git
prevent already closed errors
This commit is contained in:
parent
8549ce76bb
commit
cc26d4e040
|
@ -55,9 +55,13 @@ method write*(s: ChronosStream, msg: seq[byte], msglen = -1) {.async, gcsafe.} =
|
||||||
await s.writer.write(msg, msglen)
|
await s.writer.write(msg, msglen)
|
||||||
|
|
||||||
method close*(s: ChronosStream) {.async, gcsafe.} =
|
method close*(s: ChronosStream) {.async, gcsafe.} =
|
||||||
|
if not s.closed:
|
||||||
|
if not s.reader.closed:
|
||||||
await s.reader.closeWait()
|
await s.reader.closeWait()
|
||||||
|
|
||||||
await s.writer.finish()
|
await s.writer.finish()
|
||||||
|
|
||||||
|
if not s.writer.closed:
|
||||||
await s.writer.closeWait()
|
await s.writer.closeWait()
|
||||||
|
|
||||||
await s.client.closeWait()
|
await s.client.closeWait()
|
||||||
|
|
Loading…
Reference in New Issue