Bug 2008 - [lr-wpan] crash if ending rx while status change is in progress
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Sat, 02 May 2015 22:17:35 +0200
changeset 11346 a8900f6fe42d
parent 11345 9ae402a910f3
child 11347 3f8d3d686167
Bug 2008 - [lr-wpan] crash if ending rx while status change is in progress
src/lr-wpan/model/lr-wpan-phy.cc
src/lr-wpan/test/lr-wpan-collision-test.cc
--- a/src/lr-wpan/model/lr-wpan-phy.cc	Sat May 02 22:00:28 2015 +0200
+++ b/src/lr-wpan/model/lr-wpan-phy.cc	Sat May 02 22:17:35 2015 +0200
@@ -285,7 +285,7 @@
 
   Ptr<LrWpanSpectrumSignalParameters> lrWpanRxParams = DynamicCast<LrWpanSpectrumSignalParameters> (spectrumRxParams);
 
-  if ( lrWpanRxParams == 0)
+  if (lrWpanRxParams == 0)
     {
       CheckInterference ();
       m_signal->AddSignal (spectrumRxParams->psd);
@@ -450,7 +450,11 @@
       m_edPower.lastUpdate = now;
     }
 
-  CheckInterference ();
+  Ptr<LrWpanSpectrumSignalParameters> currentRxParams = m_currentRxPacket.first;
+  if (currentRxParams == params)
+    {
+      CheckInterference ();
+    }
 
   // Update the interference.
   m_signal->RemoveSignal (par->psd);
@@ -462,7 +466,6 @@
     }
 
   // If this is the end of the currently received packet, check if reception was successful.
-  Ptr<LrWpanSpectrumSignalParameters> currentRxParams = m_currentRxPacket.first;
   if (currentRxParams == params)
     {
       Ptr<Packet> currentPacket = currentRxParams->packetBurst->GetPackets ().front ();
--- a/src/lr-wpan/test/lr-wpan-collision-test.cc	Sat May 02 22:00:28 2015 +0200
+++ b/src/lr-wpan/test/lr-wpan-collision-test.cc	Sat May 02 22:17:35 2015 +0200
@@ -189,7 +189,7 @@
   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;