[ofw] [PATCH] winverbs: delete critical sections when no longer needed

Sean Hefty sean.hefty at intel.com
Thu Jan 14 16:49:29 PST 2010


To avoid leaking memory, we need to call DeleteCriticalSection
for all critical sections once they are no longer needed.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
This should go in WOF2-2.  I checked all critical sections
initialized using InitializeCriticalSection.

 trunk/core/winmad/user/wm_provider.cpp  |    2 ++
 trunk/core/winverbs/user/wv_base.cpp    |    1 +
 trunk/ulp/libibumad/src/umad.cpp        |    1 +
 trunk/ulp/netdirect/user/nd_adapter.cpp |    1 +
 4 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/trunk/core/winmad/user/wm_provider.cpp b/trunk/core/winmad/user/wm_provider.cpp
index 96c20da..b0adc07 100644
--- a/trunk/core/winmad/user/wm_provider.cpp
+++ b/trunk/core/winmad/user/wm_provider.cpp
@@ -64,6 +64,8 @@ CWMProvider::~CWMProvider()
 		CloseHandle(m_OverlapWrite.hEvent);
 	}
 	CloseHandle(m_hFile);
+	DeleteCriticalSection(&m_CritSecRead);
+	DeleteCriticalSection(&m_CritSecWrite);
 	InterlockedDecrement(&WmRef);
 }
 
diff --git a/trunk/core/winverbs/user/wv_base.cpp b/trunk/core/winverbs/user/wv_base.cpp
index 52e9b6e..5ed4e9f 100644
--- a/trunk/core/winverbs/user/wv_base.cpp
+++ b/trunk/core/winverbs/user/wv_base.cpp
@@ -47,6 +47,7 @@ CWVBase::~CWVBase()
 	if (m_Overlap.hEvent != NULL) {
 		CloseHandle(m_Overlap.hEvent);
 	}
+	DeleteCriticalSection(&m_CritSec);
 }
 
 STDMETHODIMP CWVBase::
diff --git a/trunk/ulp/libibumad/src/umad.cpp b/trunk/ulp/libibumad/src/umad.cpp
index 6204be0..62473e3 100644
--- a/trunk/ulp/libibumad/src/umad.cpp
+++ b/trunk/ulp/libibumad/src/umad.cpp
@@ -68,6 +68,7 @@ int umad_init(void)
 __declspec(dllexport)
 int umad_done(void)
 {
+	DeleteCriticalSection(&crit_sec);
 	return 0;
 }
 
diff --git a/trunk/ulp/netdirect/user/nd_adapter.cpp b/trunk/ulp/netdirect/user/nd_adapter.cpp
index 107a44e..805f77b 100644
--- a/trunk/ulp/netdirect/user/nd_adapter.cpp
+++ b/trunk/ulp/netdirect/user/nd_adapter.cpp
@@ -96,6 +96,7 @@ CNDAdapter::~CNDAdapter(void)
 		m_pWvProvider->Release();
 	}
 	m_pProvider->Release();
+	DeleteCriticalSection(&m_Lock);
 }
 
 STDMETHODIMP CNDAdapter::





More information about the ofw mailing list