fix last leaks with new refcounted mechanism
parent
66780ca8aa
commit
5c9a4d2328
|
@ -126,10 +126,13 @@ int main (int argc, char *argv[])
|
|||
DataRate(448000),
|
||||
210);
|
||||
// Add to Node's ApplicationList (takes ownership of pointer)
|
||||
n0->GetApplicationList()->Add(ooff0);
|
||||
ApplicationList *apl0 = n0->GetApplicationList();
|
||||
apl0->Add(ooff0);
|
||||
apl0->Unref ();
|
||||
// Start the application
|
||||
ooff0->Start(Seconds(1.0));
|
||||
ooff0->Stop (Seconds(10.0));
|
||||
ooff0->Unref ();
|
||||
|
||||
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
|
||||
OnOffApplication* ooff1 = new OnOffApplication(
|
||||
|
@ -141,15 +144,23 @@ int main (int argc, char *argv[])
|
|||
DataRate(448000),
|
||||
210);
|
||||
// Add to Node's ApplicationList (takes ownership of pointer)
|
||||
n3->GetApplicationList()->Add(ooff1);
|
||||
ApplicationList *apl3 = n3->GetApplicationList();
|
||||
apl3->Add(ooff1);
|
||||
apl3->Unref ();
|
||||
// Start the application
|
||||
ooff1->Start(Seconds(1.1));
|
||||
ooff1->Stop (Seconds(10.0));
|
||||
ooff1->Unref ();
|
||||
|
||||
// Here, finish off packet routing configuration
|
||||
// This will likely set by some global StaticRouting object in the future
|
||||
n0->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
|
||||
n3->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
|
||||
Ipv4 *ipv4;
|
||||
ipv4 = n0->GetIpv4();
|
||||
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
|
||||
ipv4->Unref ();
|
||||
ipv4 = n3->GetIpv4();
|
||||
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
|
||||
ipv4->Unref ();
|
||||
|
||||
n0->Unref ();
|
||||
n1->Unref ();
|
||||
|
|
|
@ -84,6 +84,9 @@ PointToPointTopology::AddPointToPointLink(
|
|||
ip1->AddHostRouteTo (addr2, index1);
|
||||
ip2->AddHostRouteTo (addr1, index2);
|
||||
|
||||
ip1->Unref ();
|
||||
ip2->Unref ();
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ ApplicationList* ApplicationList::Copy(Node * n) const
|
|||
void
|
||||
ApplicationList::Add(Application* a)
|
||||
{
|
||||
a->Ref ();
|
||||
m_apps.push_back(a);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,17 @@ InternetNode::InternetNode()
|
|||
m_applicationList = new ApplicationList(this);
|
||||
m_l3Demux = new L3Demux(this);
|
||||
m_ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
m_l3Demux->Insert (Ipv4 (this));
|
||||
m_l3Demux->Insert (Arp (this));
|
||||
m_ipv4L4Demux->Insert (Udp (this));
|
||||
Ipv4 *ipv4 = new Ipv4 (this);
|
||||
Arp *arp = new Arp (this);
|
||||
Udp *udp = new Udp (this);
|
||||
|
||||
m_l3Demux->Insert (ipv4);
|
||||
m_l3Demux->Insert (arp);
|
||||
m_ipv4L4Demux->Insert (udp);
|
||||
|
||||
ipv4->Unref ();
|
||||
arp->Unref ();
|
||||
udp->Unref ();
|
||||
}
|
||||
|
||||
InternetNode::~InternetNode ()
|
||||
|
@ -161,7 +169,9 @@ InternetNode::DoAddDevice (NetDevice *device) const
|
|||
bool
|
||||
InternetNode::ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const
|
||||
{
|
||||
L3Protocol *target = GetL3Demux()->PeekProtocol (protocolNumber);
|
||||
L3Demux *demux = GetL3Demux();
|
||||
L3Protocol *target = demux->PeekProtocol (protocolNumber);
|
||||
demux->Unref ();
|
||||
if (target != 0)
|
||||
{
|
||||
Packet packet = p;
|
||||
|
|
|
@ -56,16 +56,6 @@ Ipv4L4Demux::Dispose (void)
|
|||
}
|
||||
}
|
||||
|
||||
Ipv4L4Demux*
|
||||
Ipv4L4Demux::Copy(Node *node) const
|
||||
{
|
||||
Ipv4L4Demux * copy = new Ipv4L4Demux(node);
|
||||
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
|
||||
{
|
||||
copy->Insert(*(*i));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
TraceResolver *
|
||||
Ipv4L4Demux::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
|
@ -83,12 +73,11 @@ Ipv4L4Demux::CreateTraceResolver (TraceContext const &context)
|
|||
}
|
||||
return resolver;
|
||||
}
|
||||
Ipv4L4Protocol*
|
||||
Ipv4L4Demux::Insert(const Ipv4L4Protocol&protocol)
|
||||
void
|
||||
Ipv4L4Demux::Insert(Ipv4L4Protocol *protocol)
|
||||
{
|
||||
Ipv4L4Protocol* copy = protocol.Copy(m_node); // Make a copy of the protocol
|
||||
m_protocols.push_back (copy);
|
||||
return copy;
|
||||
protocol->Ref ();
|
||||
m_protocols.push_back (protocol);
|
||||
}
|
||||
Ipv4L4Protocol*
|
||||
Ipv4L4Demux::PeekProtocol(int protocolNumber)
|
||||
|
|
|
@ -47,12 +47,6 @@ public:
|
|||
|
||||
void Dispose (void);
|
||||
|
||||
/**
|
||||
* \param node the node on which the returned copy will run.
|
||||
* \returns a deep copy of this L4 Demux.
|
||||
*/
|
||||
Ipv4L4Demux* Copy(Node *node) const;
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
|
@ -71,7 +65,7 @@ public:
|
|||
* a working L4 Protocol and returned from this method.
|
||||
* The caller does not get ownership of the returned pointer.
|
||||
*/
|
||||
Ipv4L4Protocol* Insert(const Ipv4L4Protocol&protocol);
|
||||
void Insert(Ipv4L4Protocol *protocol);
|
||||
/**
|
||||
* \param protocolNumber number of protocol to lookup
|
||||
* in this L4 Demux
|
||||
|
|
|
@ -62,13 +62,6 @@ public:
|
|||
*/
|
||||
int GetVersion() const;
|
||||
|
||||
/**
|
||||
* \param node the node on which the copy should be running
|
||||
* \returns a new instance of this L4 Protocol.
|
||||
*
|
||||
* Perform a deep copy of the L4 Protocol
|
||||
*/
|
||||
virtual Ipv4L4Protocol* Copy(Node *node) const = 0;
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,22 +73,10 @@ L3Demux::CreateTraceResolver (TraceContext const &context) const
|
|||
return resolver;
|
||||
}
|
||||
|
||||
L3Demux* L3Demux::Copy(Node *node) const
|
||||
void L3Demux::Insert(L3Protocol *p)
|
||||
{
|
||||
L3Demux *copy = new L3Demux (node);
|
||||
for (L3Map_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
|
||||
{
|
||||
copy->Insert(*i->second);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
L3Protocol* L3Demux::Insert(const L3Protocol& l3p)
|
||||
{
|
||||
L3Protocol* l = l3p.Copy(m_node); // Make a copy of the protocol
|
||||
m_protocols.insert(L3Map_t::value_type(l3p.GetProtocolNumber (), l));
|
||||
return l;
|
||||
p->Ref ();
|
||||
m_protocols.insert(L3Map_t::value_type(p->GetProtocolNumber (), p));
|
||||
}
|
||||
|
||||
L3Protocol*
|
||||
|
|
|
@ -49,12 +49,6 @@ public:
|
|||
|
||||
void Dispose (void);
|
||||
|
||||
/**
|
||||
* \param node the node on which the returned copy will run.
|
||||
* \returns a deep copy of this L3 Demux.
|
||||
*/
|
||||
L3Demux* Copy(Node *node) const;
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
|
@ -67,7 +61,6 @@ public:
|
|||
|
||||
/**
|
||||
* \param protocol a template for the protocol to add to this L3 Demux.
|
||||
* \returns the L3Protocol effectively added.
|
||||
*
|
||||
* Invoke Copy on the input template to get a copy of the input
|
||||
* protocol which can be used on the Node on which this L3 Demux
|
||||
|
@ -75,7 +68,7 @@ public:
|
|||
* a working L3 Protocol and returned from this method.
|
||||
* The caller does not get ownership of the returned pointer.
|
||||
*/
|
||||
ns3::L3Protocol* Insert(const ns3::L3Protocol& protocol);
|
||||
void Insert(ns3::L3Protocol * protocol);
|
||||
/**
|
||||
* \param protocolNumber number of protocol to lookup
|
||||
* in this L4 Demux
|
||||
|
|
|
@ -48,8 +48,6 @@ public:
|
|||
|
||||
virtual void Dispose (void) = 0;
|
||||
|
||||
virtual L3Protocol* Copy(Node *node) const = 0;
|
||||
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
|
||||
/**
|
||||
* Lower layer calls this method after calling L3Demux::Lookup
|
||||
|
|
|
@ -34,8 +34,8 @@ UdpSocket::UdpSocket (Node *node)
|
|||
m_shutdownRecv (false),
|
||||
m_connected (false)
|
||||
{
|
||||
NS_ASSERT (m_node->GetUdp () != 0);
|
||||
m_udp = m_node->GetUdp ();
|
||||
NS_ASSERT (m_udp != 0);
|
||||
m_node->Ref ();
|
||||
}
|
||||
UdpSocket::~UdpSocket ()
|
||||
|
|
Loading…
Reference in New Issue