From fc9f640628e2ab5b74732fff09d05f05e6af7640 Mon Sep 17 00:00:00 2001 From: Hrishikesh Hiraskar Date: Sat, 26 Sep 2020 19:19:03 +0000 Subject: [PATCH] fd-net-device: Move setting of m_nodeId to FdNetDevice::SetNode m_nodeId was set in FdNetDevice::StartDevice. This commit moves it to FdNetDevice::SetNode so that is it set whenever node is set. --- src/fd-net-device/model/fd-net-device.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/fd-net-device/model/fd-net-device.cc b/src/fd-net-device/model/fd-net-device.cc index bc2eef4f3..73368864d 100644 --- a/src/fd-net-device/model/fd-net-device.cc +++ b/src/fd-net-device/model/fd-net-device.cc @@ -239,13 +239,6 @@ FdNetDevice::StartDevice (void) NS_LOG_DEBUG ("FdNetDevice::Start(): Failure, invalid file descriptor."); return; } - // - // A similar story exists for the node ID. We can't just naively do a - // GetNode ()->GetId () since GetNode is going to give us a Ptr which - // is reference counted. We need to stash away the node ID for use in the - // read thread. - // - m_nodeId = GetNode ()->GetId (); m_fdReader = DoCreateFdReader (); m_fdReader->Start (m_fd, MakeCallback (&FdNetDevice::ReceiveCallback, this)); @@ -786,6 +779,11 @@ void FdNetDevice::SetNode (Ptr node) { m_node = node; + + // Save the node ID for use in the read thread, to avoid having + // to make a call to GetNode ()->GetId () that increments + // Ptr's reference count. + m_nodeId = node->GetId (); } bool