From 4e5366f09f81da92fbf1fd3496cd4e0c7d640859 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 2 May 2015 22:17:35 +0200 Subject: [PATCH] Bug 2008 - [lr-wpan] crash if ending rx while status change is in progress --- src/lr-wpan/model/lr-wpan-phy.cc | 9 ++++++--- src/lr-wpan/test/lr-wpan-collision-test.cc | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lr-wpan/model/lr-wpan-phy.cc b/src/lr-wpan/model/lr-wpan-phy.cc index e2c8d2ed0..40a2d23b9 100644 --- a/src/lr-wpan/model/lr-wpan-phy.cc +++ b/src/lr-wpan/model/lr-wpan-phy.cc @@ -285,7 +285,7 @@ LrWpanPhy::StartRx (Ptr spectrumRxParams) Ptr lrWpanRxParams = DynamicCast (spectrumRxParams); - if ( lrWpanRxParams == 0) + if (lrWpanRxParams == 0) { CheckInterference (); m_signal->AddSignal (spectrumRxParams->psd); @@ -450,7 +450,11 @@ LrWpanPhy::EndRx (Ptr par) m_edPower.lastUpdate = now; } - CheckInterference (); + Ptr currentRxParams = m_currentRxPacket.first; + if (currentRxParams == params) + { + CheckInterference (); + } // Update the interference. m_signal->RemoveSignal (par->psd); @@ -462,7 +466,6 @@ LrWpanPhy::EndRx (Ptr par) } // If this is the end of the currently received packet, check if reception was successful. - Ptr currentRxParams = m_currentRxPacket.first; if (currentRxParams == params) { Ptr currentPacket = currentRxParams->packetBurst->GetPackets ().front (); diff --git a/src/lr-wpan/test/lr-wpan-collision-test.cc b/src/lr-wpan/test/lr-wpan-collision-test.cc index 659aff502..50af2f27c 100644 --- a/src/lr-wpan/test/lr-wpan-collision-test.cc +++ b/src/lr-wpan/test/lr-wpan-collision-test.cc @@ -189,7 +189,7 @@ LrWpanCollisionTestCase::DoRun (void) Simulator::Run (); std::cout << "m_rxPackets = " << int(m_rxPackets) << std::endl; - NS_TEST_EXPECT_MSG_EQ (m_rxPackets, 0, "Received a packet (as expected)"); + NS_TEST_EXPECT_MSG_EQ (m_rxPackets, 1, "Received a packet (as expected)"); // Fourth case: two concurrent tx and ACKs std::cout << "*** Fourth test " << std::endl;