[ofw] [WOF2-2] [PATCH v2 2/4] winverbs/nd: allow retrying ND:Connect()

Sean Hefty sean.hefty at intel.com
Tue Mar 9 14:49:28 PST 2010


The ND documentation specifies that ND:Connect() should be retry-able.
Add this support to the winverbs ND provider.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
change from v1:
fixed issue where server side of ND tests could crash

 trunk/ulp/netdirect/user/nd_connect.cpp |   22 ++++++++++++++++++++--
 trunk/ulp/netdirect/user/nd_connect.h   |    1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/trunk/ulp/netdirect/user/nd_connect.cpp b/trunk/ulp/netdirect/user/nd_connect.cpp
index 81d5f7b..3042530 100644
--- a/trunk/ulp/netdirect/user/nd_connect.cpp
+++ b/trunk/ulp/netdirect/user/nd_connect.cpp
@@ -37,15 +37,26 @@ CNDConnector::CNDConnector(CNDAdapter *pAdapter)
 	pAdapter->AddRef();
 	m_pAdapter = pAdapter;
 	m_pWvConnEp = NULL;
+	m_Connects = 0;
 }
 
 STDMETHODIMP CNDConnector::
 Init(void)
 {
+	IWVConnectEndpoint *ep;
 	HRESULT hr;
 
-	hr = m_pAdapter->m_pWvProvider->CreateConnectEndpoint(&m_pWvConnEp);
-	return NDConvertWVStatus(hr);
+	hr = m_pAdapter->m_pWvProvider->CreateConnectEndpoint(&ep);
+	if (FAILED(hr)) {
+		return NDConvertWVStatus(hr);
+	}
+
+	if (m_pWvConnEp != NULL) {
+		m_pWvConnEp->Release();
+	}
+
+	m_pWvConnEp = ep;
+	return ND_SUCCESS;
 }
 
 CNDConnector::~CNDConnector()
@@ -132,6 +143,13 @@ Connect(INDEndpoint* pEndpoint,
 	IBAT_PATH_BLOB path;
 	HRESULT hr;
 
+	if (m_Connects++ > 0) {
+		hr = Init();
+		if (FAILED(hr)) {
+			goto out;
+		}
+	}
+
 	RtlCopyMemory(&addr, &m_pAdapter->m_Address, AddressLength);
 	if (addr.Sa.sa_family == AF_INET) {
 		addr.Sin.sin_port = LocalPort;
diff --git a/trunk/ulp/netdirect/user/nd_connect.h b/trunk/ulp/netdirect/user/nd_connect.h
index 2da2f22..688fedc 100644
--- a/trunk/ulp/netdirect/user/nd_connect.h
+++ b/trunk/ulp/netdirect/user/nd_connect.h
@@ -114,6 +114,7 @@ public:
 
 protected:
 	STDMETHODIMP		Init();
+	int					m_Connects;
 };
 
 #endif // _ND_CONNECTOR_H_





More information about the ofw mailing list