mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-10 08:57:56 -05:00
Compare commits
2 Commits
autotls-re
...
fix-sendMs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1342b45b29 | ||
|
|
a65ce6a47a |
@@ -288,22 +288,28 @@ proc sendMsgSlow(p: PubSubPeer, msg: seq[byte]) {.async.} =
|
||||
if p.sendConn == nil:
|
||||
# Wait for a send conn to be setup. `connectOnce` will
|
||||
# complete this even if the sendConn setup failed
|
||||
await p.connectedFut
|
||||
try:
|
||||
await p.connectedFut
|
||||
except CatchableError as exc:
|
||||
debug "Error when waiting for a send conn to be setup", msg = exc.msg, p
|
||||
|
||||
var conn = p.sendConn
|
||||
if conn == nil or conn.closed():
|
||||
debug "No send connection", p, msg = shortLog(msg)
|
||||
debug "No send connection", msg = shortLog(msg), p
|
||||
return
|
||||
|
||||
trace "sending encoded msg to peer", conn, encoded = shortLog(msg)
|
||||
await sendMsgContinue(conn, conn.writeLp(msg))
|
||||
trace "sending encoded msg to peer", conn, encoded = shortLog(msg), p
|
||||
try:
|
||||
await sendMsgContinue(conn, conn.writeLp(msg))
|
||||
except CancelledError as exc:
|
||||
trace "Continuation for pending `sendMsg` future has been unexpectedly cancelled"
|
||||
|
||||
proc sendMsg(p: PubSubPeer, msg: seq[byte]): Future[void] =
|
||||
if p.sendConn != nil and not p.sendConn.closed():
|
||||
# Fast path that avoids copying msg (which happens for {.async.})
|
||||
let conn = p.sendConn
|
||||
|
||||
trace "sending encoded msg to peer", conn, encoded = shortLog(msg)
|
||||
trace "sending encoded msg to peer", conn, encoded = shortLog(msg), p
|
||||
let f = conn.writeLp(msg)
|
||||
if not f.completed():
|
||||
sendMsgContinue(conn, f)
|
||||
|
||||
Reference in New Issue
Block a user