# HG changeset patch # User Mathieu Lacage # Date 1194531742 -3600 # Node ID a651a0131bfed2d0ed87edcbd407e785d596270f # Parent 2914851fd23842f9e2005c1e155dc1d5103cfe98 make sure that m_listener is not reset to zero _after_ calling a user-provided callback. This allows the user-provided callback to set the m_listener member to a new value if it wants to start a new transmission diff -r 2914851fd238 -r a651a0131bfe src/devices/wifi/mac-low.cc --- a/src/devices/wifi/mac-low.cc Thu Nov 08 13:58:26 2007 +0100 +++ b/src/devices/wifi/mac-low.cc Thu Nov 08 15:22:22 2007 +0100 @@ -23,6 +23,7 @@ #include "ns3/simulator.h" #include "ns3/tag.h" #include "ns3/log.h" +#include "ns3/node.h" #include "mac-low.h" #include "wifi-phy.h" @@ -34,7 +35,7 @@ NS_LOG_COMPONENT_DEFINE ("MacLow"); #define MY_DEBUG(x) \ - NS_LOG_DEBUG (Simulator::Now () << " " << x) + NS_LOG_DEBUG (Simulator::Now () << " " << m_device->GetNode ()->GetId () << " " << x) namespace ns3 { @@ -364,7 +365,7 @@ //NS_ASSERT (m_phy->IsStateIdle ()); - MY_DEBUG ("startTx size="<< GetCurrentSize () << ", to=" << m_currentHdr.GetAddr1()); + MY_DEBUG ("startTx size="<< GetCurrentSize () << ", to=" << m_currentHdr.GetAddr1()<<", listener="<ReportRtsFailed (); m_hasCurrent = false; - m_listener->MissedCts (); + MacLowTransmissionListener *listener = m_listener; m_listener = 0; + listener->MissedCts (); } void MacLow::NormalAckTimeout (void) { + MY_DEBUG ("normal ack timeout"); MacStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportDataFailed (); - m_listener->MissedAck (); + MacLowTransmissionListener *listener = m_listener; m_listener = 0; + listener->MissedAck (); } void MacLow::FastAckTimeout (void) { MacStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportDataFailed (); + MacLowTransmissionListener *listener = m_listener; + m_listener = 0; if (m_phy->IsStateIdle ()) { MY_DEBUG ("fast Ack idle missed"); - m_listener->MissedAck (); + listener->MissedAck (); } - m_listener = 0; + else + { + MY_DEBUG ("fast Ack ok"); + } } void MacLow::SuperFastAckTimeout () { MacStation *station = GetStation (m_currentHdr.GetAddr1 ()); station->ReportDataFailed (); + MacLowTransmissionListener *listener = m_listener; + m_listener = 0; if (m_phy->IsStateIdle ()) { MY_DEBUG ("super fast Ack failed"); - m_listener->MissedAck (); + listener->MissedAck (); } else { MY_DEBUG ("super fast Ack ok"); - m_listener->GotAck (0.0, WifiMode ()); + listener->GotAck (0.0, WifiMode ()); } - m_listener = 0; } void @@ -974,7 +984,9 @@ void MacLow::FastAckFailedTimeout (void) { - m_listener->MissedAck (); + MacLowTransmissionListener *listener = m_listener; + m_listener = 0; + listener->MissedAck (); MY_DEBUG ("fast Ack busy but missed"); }