network: Fix valgrind errors due to ConnectQueueTraces

This commit is contained in:
Stefano Avallone
2017-03-27 11:08:38 +02:00
parent 2a22d760b3
commit 3f387016b9
2 changed files with 25 additions and 12 deletions

View File

@@ -193,6 +193,20 @@ void
NetDeviceQueueInterface::DoDispose (void)
{
NS_LOG_FUNCTION (this);
for (auto t : m_traceMap)
{
if (!t.first->TraceDisconnectWithoutContext ("Enqueue", t.second[0])
|| !t.first->TraceDisconnectWithoutContext ("Dequeue", t.second[1])
|| !t.first->TraceDisconnectWithoutContext ("DropAfterDequeue", t.second[1])
|| !t.first->TraceDisconnectWithoutContext ("DropBeforeEnqueue", t.second[2]))
{
NS_LOG_WARN ("NetDeviceQueueInterface: Trying to disconnected a callback that"
" has not been connected to a traced callback");
}
}
m_traceMap.clear ();
m_txQueuesVector.clear ();
Object::DoDispose ();
}

View File

@@ -21,6 +21,7 @@
#define NET_DEVICE_QUEUE_INTERFACE_H
#include <vector>
#include <map>
#include "ns3/callback.h"
#include "ns3/object.h"
#include "ns3/ptr.h"
@@ -333,6 +334,7 @@ private:
SelectQueueCallback m_selectQueueCallback; //!< Select queue callback
uint8_t m_numTxQueues; //!< Number of transmission queues to create
bool m_lateTxQueuesCreation; //!< True if a device wants to create the TX queues by itself
std::map<Ptr<QueueBase>, std::vector<CallbackBase> > m_traceMap; //!< Map storing all the connected traces
};
@@ -355,18 +357,15 @@ NetDeviceQueueInterface::ConnectQueueTraces (Ptr<Queue<Item> > queue, uint8_t tx
NS_ASSERT (queue != 0);
NS_ASSERT (txq < GetNTxQueues ());
queue->TraceConnectWithoutContext ("Enqueue",
MakeBoundCallback (&NetDeviceQueue::PacketEnqueued<Item>,
queue, this, txq));
queue->TraceConnectWithoutContext ("Dequeue",
MakeBoundCallback (&NetDeviceQueue::PacketDequeued<Item>,
queue, this, txq));
queue->TraceConnectWithoutContext ("DropAfterDequeue",
MakeBoundCallback (&NetDeviceQueue::PacketDequeued<Item>,
queue, this, txq));
queue->TraceConnectWithoutContext ("DropBeforeEnqueue",
MakeBoundCallback (&NetDeviceQueue::PacketDiscarded<Item>,
queue, this, txq));
m_traceMap.emplace (queue, std::initializer_list<CallbackBase> {
MakeBoundCallback (&NetDeviceQueue::PacketEnqueued<Item>, queue, this, txq),
MakeBoundCallback (&NetDeviceQueue::PacketDequeued<Item>, queue, this, txq),
MakeBoundCallback (&NetDeviceQueue::PacketDiscarded<Item>, queue, this, txq) });
queue->TraceConnectWithoutContext ("Enqueue", m_traceMap[queue][0]);
queue->TraceConnectWithoutContext ("Dequeue", m_traceMap[queue][1]);
queue->TraceConnectWithoutContext ("DropAfterDequeue", m_traceMap[queue][1]);
queue->TraceConnectWithoutContext ("DropBeforeEnqueue", m_traceMap[queue][2]);
}
template <typename Item>