winverbs/nd: allow retrying connect
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 2 Apr 2010 23:32:04 +0000 (23:32 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 2 Apr 2010 23:32:04 +0000 (23:32 +0000)
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@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2762 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/netdirect/user/nd_connect.cpp
ulp/netdirect/user/nd_connect.h

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