From 123caf7cf3e77a237a7049e2b32809b7f2b0c5f3 Mon Sep 17 00:00:00 2001 From: "Juan C. Granda" Date: Wed, 15 Jan 2014 23:35:55 +0100 Subject: [PATCH] Bug 1739 - The endpoint is not deallocated for UDP sockets --- RELEASE_NOTES | 1 + src/internet/model/tcp-socket-base.h | 2 +- src/internet/model/udp-socket-impl.cc | 20 ++++++++++++++++++++ src/internet/model/udp-socket-impl.h | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 5e7a9ffdb..0981cf914 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -29,6 +29,7 @@ New user-visible features Bugs fixed ---------- +- Bug 1739 - The endpoint is not deallocated for UDP sockets - Bug 1786 - os << int64x64_t prints un-normalized fractional values - Bug 1821 - Setting an interface to Down state will cause various asserts in IPv6 - Bug 1837 - AODV crashes when using multiple interfaces diff --git a/src/internet/model/tcp-socket-base.h b/src/internet/model/tcp-socket-base.h index 086a1a57e..a9ece0a9a 100644 --- a/src/internet/model/tcp-socket-base.h +++ b/src/internet/model/tcp-socket-base.h @@ -341,7 +341,7 @@ protected: void Destroy6 (void); /** - * \brief Deallocate m_endPoint + * \brief Deallocate m_endPoint and m_endPoint6 */ void DeallocateEndPoint (void); diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc index 77bb7ef03..14eb7efb0 100644 --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -180,6 +180,25 @@ UdpSocketImpl::Destroy6 (void) m_endPoint6 = 0; } +/* Deallocate the end point and cancel all the timers */ +void +UdpSocketImpl::DeallocateEndPoint (void) +{ + if (m_endPoint != 0) + { + m_endPoint->SetDestroyCallback (MakeNullCallback ()); + m_udp->DeAllocate (m_endPoint); + m_endPoint = 0; + } + if (m_endPoint6 != 0) + { + m_endPoint6->SetDestroyCallback (MakeNullCallback ()); + m_udp->DeAllocate (m_endPoint6); + m_endPoint6 = 0; + } +} + + int UdpSocketImpl::FinishBind (void) { @@ -318,6 +337,7 @@ UdpSocketImpl::Close (void) } m_shutdownRecv = true; m_shutdownSend = true; + DeallocateEndPoint (); return 0; } diff --git a/src/internet/model/udp-socket-impl.h b/src/internet/model/udp-socket-impl.h index 05cfef993..8b1de5e39 100644 --- a/src/internet/model/udp-socket-impl.h +++ b/src/internet/model/udp-socket-impl.h @@ -158,6 +158,11 @@ private: */ void Destroy6 (void); + /** + * \brief Deallocate m_endPoint and m_endPoint6 + */ + void DeallocateEndPoint (void); + /** * \brief Send a packet * \param p packet