From 3c4c10d871880314da27a5767a744f88fb140544 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 15 Jun 2020 13:37:25 -0600 Subject: [PATCH] con't crash on nil ptr --- libp2p/muxers/mplex/mplex.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim index bf62fd0b3..c2d06cc0f 100644 --- a/libp2p/muxers/mplex/mplex.nim +++ b/libp2p/muxers/mplex/mplex.nim @@ -75,11 +75,13 @@ method handle*(m: Mplex) {.async, gcsafe.} = msgType = msgType, data = data.shortLog, oid = m.oid + let initiator = bool(ord(msgType) and 1) var channel: LPChannel if MessageType(msgType) != MessageType.New: let channels = m.getChannelList(initiator) if id notin channels: + trace "Channel not found, skipping", id = id, initiator = initiator, msg = msgType, @@ -98,11 +100,9 @@ method handle*(m: Mplex) {.async, gcsafe.} = of MessageType.New: let name = string.fromBytes(data) channel = await m.newStreamInternal(false, id, name) - logScope: - name = channel.name - chann_iod = channel.oid - trace "created channel" + trace "created channel", name = channel.name, + chann_iod = channel.oid if not isNil(m.streamHandler): let stream = newConnection(channel)