View | Details | Raw Unified | Return to bug 1377
Collapse All | Expand All

(-)a/src/internet/model/tcp-socket-base.cc (-3 / +21 lines)
 Lines 635-641    Link Here 
635
  if (m_endPoint6 != 0)
635
  if (m_endPoint6 != 0)
636
    {
636
    {
637
      m_endPoint6->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp6, Ptr<TcpSocketBase> (this)));
637
      m_endPoint6->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp6, Ptr<TcpSocketBase> (this)));
638
      m_endPoint6->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
638
      m_endPoint6->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy6, Ptr<TcpSocketBase> (this)));
639
    }
639
    }
640
640
641
  return 0;
641
  return 0;
 Lines 1422-1429    Link Here 
1422
TcpSocketBase::Destroy (void)
1422
TcpSocketBase::Destroy (void)
1423
{
1423
{
1424
  NS_LOG_FUNCTION (this);
1424
  NS_LOG_FUNCTION (this);
1425
  m_node = 0;
1426
  m_endPoint = 0;
1425
  m_endPoint = 0;
1426
  if (m_tcp != 0)
1427
    {
1428
      std::vector<Ptr<TcpSocketBase> >::iterator it
1429
        = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
1430
      if (it != m_tcp->m_sockets.end ())
1431
        {
1432
          m_tcp->m_sockets.erase (it);
1433
        }
1434
    }
1435
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1436
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
1437
  CancelAllTimers ();
1438
}
1439
1440
/** Kill this socket. This is a callback function configured to m_endpoint in
1441
   SetupCallback(), invoked when the endpoint is destroyed. */
1442
void
1443
TcpSocketBase::Destroy6 (void)
1444
{
1445
  NS_LOG_FUNCTION (this);
1427
  m_endPoint6 = 0;
1446
  m_endPoint6 = 0;
1428
  if (m_tcp != 0)
1447
  if (m_tcp != 0)
1429
    {
1448
    {
 Lines 1433-1439    Link Here 
1433
        {
1452
        {
1434
          m_tcp->m_sockets.erase (it);
1453
          m_tcp->m_sockets.erase (it);
1435
        }
1454
        }
1436
      m_tcp = 0;
1437
    }
1455
    }
1438
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1456
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1439
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
1457
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
(-)a/src/internet/model/tcp-socket-base.h (+1 lines)
 Lines 148-153    Link Here 
148
  int DoClose (void); // Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
148
  int DoClose (void); // Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
149
  void CloseAndNotify (void); // To CLOSED state, notify upper layer, and deallocate end point
149
  void CloseAndNotify (void); // To CLOSED state, notify upper layer, and deallocate end point
150
  void Destroy (void); // Kill this socket by zeroing its attributes
150
  void Destroy (void); // Kill this socket by zeroing its attributes
151
  void Destroy6 (void); // Kill this socket by zeroing its attributes
151
  void DeallocateEndPoint (void); // Deallocate m_endPoint
152
  void DeallocateEndPoint (void); // Deallocate m_endPoint
152
  void PeerClose (Ptr<Packet>, const TcpHeader&); // Received a FIN from peer, notify rx buffer
153
  void PeerClose (Ptr<Packet>, const TcpHeader&); // Received a FIN from peer, notify rx buffer
153
  void DoPeerClose (void); // FIN is in sequence, notify app and respond with a FIN
154
  void DoPeerClose (void); // FIN is in sequence, notify app and respond with a FIN
(-)a/src/internet/model/udp-socket-impl.cc (-5 / +35 lines)
 Lines 86-91    Link Here 
86
86
87
  // XXX todo:  leave any multicast groups that have been joined
87
  // XXX todo:  leave any multicast groups that have been joined
88
  m_node = 0;
88
  m_node = 0;
89
  /**
90
   * Note: actually this function is called AFTER
91
   * UdpSocketImpl::Destroy or UdpSocketImpl::Destroy6
92
   * so the code below is unnecessary in normal operations
93
   */
89
  if (m_endPoint != 0)
94
  if (m_endPoint != 0)
90
    {
95
    {
91
      NS_ASSERT (m_udp != 0);
96
      NS_ASSERT (m_udp != 0);
 Lines 101-106    Link Here 
101
      m_udp->DeAllocate (m_endPoint);
106
      m_udp->DeAllocate (m_endPoint);
102
      NS_ASSERT (m_endPoint == 0);
107
      NS_ASSERT (m_endPoint == 0);
103
    }
108
    }
109
  if (m_endPoint6 != 0)
110
    {
111
      NS_ASSERT (m_udp != 0);
112
      /**
113
       * Note that this piece of code is a bit tricky:
114
       * when DeAllocate is called, it will call into
115
       * Ipv4EndPointDemux::Deallocate which triggers
116
       * a delete of the associated endPoint which triggers
117
       * in turn a call to the method UdpSocketImpl::Destroy below
118
       * will will zero the m_endPoint field.
119
       */
120
      NS_ASSERT (m_endPoint6 != 0);
121
      m_udp->DeAllocate (m_endPoint6);
122
      NS_ASSERT (m_endPoint6 == 0);
123
    }
104
  m_udp = 0;
124
  m_udp = 0;
105
}
125
}
106
126
 Lines 143-169    Link Here 
143
UdpSocketImpl::Destroy (void)
163
UdpSocketImpl::Destroy (void)
144
{
164
{
145
  NS_LOG_FUNCTION_NOARGS ();
165
  NS_LOG_FUNCTION_NOARGS ();
146
  m_node = 0;
147
  m_endPoint = 0;
166
  m_endPoint = 0;
148
  m_udp = 0;
167
}
168
169
void
170
UdpSocketImpl::Destroy6 (void)
171
{
172
  NS_LOG_FUNCTION_NOARGS ();
173
  m_endPoint6 = 0;
149
}
174
}
150
175
151
int
176
int
152
UdpSocketImpl::FinishBind (void)
177
UdpSocketImpl::FinishBind (void)
153
{
178
{
154
  NS_LOG_FUNCTION_NOARGS ();
179
  NS_LOG_FUNCTION_NOARGS ();
180
  bool done = false;
155
  if (m_endPoint != 0)
181
  if (m_endPoint != 0)
156
    {
182
    {
157
      m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
183
      m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
158
      m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
184
      m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
159
      m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
185
      m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
160
      return 0;
186
      done = true;
161
    }
187
    }
162
  else if (m_endPoint6 != 0)
188
  if (m_endPoint6 != 0)
163
    {
189
    {
164
      m_endPoint6->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp6, Ptr<UdpSocketImpl> (this)));
190
      m_endPoint6->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp6, Ptr<UdpSocketImpl> (this)));
165
      m_endPoint6->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp6, Ptr<UdpSocketImpl> (this)));
191
      m_endPoint6->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp6, Ptr<UdpSocketImpl> (this)));
166
      m_endPoint6->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
192
      m_endPoint6->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy6, Ptr<UdpSocketImpl> (this)));
193
      done = true;
194
    }
195
  if (done)
196
    {
167
      return 0;
197
      return 0;
168
    }
198
    }
169
  return -1;
199
  return -1;
(-)a/src/internet/model/udp-socket-impl.h (+1 lines)
 Lines 108-113    Link Here 
108
                  Ptr<Ipv4Interface> incomingInterface);
108
                  Ptr<Ipv4Interface> incomingInterface);
109
  void ForwardUp6 (Ptr<Packet> p, Ipv6Address saddr, Ipv6Address daddr, uint16_t port);
109
  void ForwardUp6 (Ptr<Packet> p, Ipv6Address saddr, Ipv6Address daddr, uint16_t port);
110
  void Destroy (void);
110
  void Destroy (void);
111
  void Destroy6 (void);
111
  int DoSend (Ptr<Packet> p);
112
  int DoSend (Ptr<Packet> p);
112
  int DoSendTo (Ptr<Packet> p, const Address &daddr);
113
  int DoSendTo (Ptr<Packet> p, const Address &daddr);
113
  int DoSendTo (Ptr<Packet> p, Ipv4Address daddr, uint16_t dport);
114
  int DoSendTo (Ptr<Packet> p, Ipv4Address daddr, uint16_t dport);
(-)a/src/internet/test/ipv6-dual-stack-test-suite.cc (+1 lines)
 Lines 296-301    Link Here 
296
void
296
void
297
DualStackTestCase::DoTeardown (void)
297
DualStackTestCase::DoTeardown (void)
298
{
298
{
299
  Simulator::Destroy ();
299
}
300
}
300
301
301
302

Return to bug 1377