[ofw] [PATCH 4/12] nd2/provider: set file completion notification mode

Hefty, Sean sean.hefty at intel.com
Tue Jul 27 00:57:49 PDT 2010


Add an Init() call to the NDProvider in order to report
failure during initialization.  Set the winverbs file handle
completion notification mode according to the latest ND spec.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
 trunk/ulp/netdirect2/user/nd_provider.cpp |   32 +++++++++++++++++++----------
 trunk/ulp/netdirect2/user/nd_provider.h   |   30 +++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/trunk/ulp/netdirect2/user/nd_provider.cpp b/trunk/ulp/netdirect2/user/nd_provider.cpp
index 968193d..6f94b71 100644
--- a/trunk/ulp/netdirect2/user/nd_provider.cpp
+++ b/trunk/ulp/netdirect2/user/nd_provider.cpp
@@ -33,7 +33,26 @@
 
 CNDProvider::CNDProvider()
 {
-	WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);
+	m_pWvProvider = NULL;
+}
+
+STDMETHODIMP CNDProvider::
+Init()
+{
+	HRESULT hr;
+
+	hr = WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);
+	if (FAILED(hr)) {
+		return hr;
+	}
+
+	if (!SetFileCompletionNotificationModes(m_pWvProvider->GetFileHandle(),
+											FILE_SKIP_COMPLETION_PORT_ON_SUCCESS |
+											FILE_SKIP_SET_EVENT_ON_HANDLE)) {
+		return HRESULT_FROM_WIN32(GetLastError());
+	}
+
+	return ND_SUCCESS;
 }
 
 CNDProvider::~CNDProvider()
@@ -79,10 +98,6 @@ QueryAdapterAddressList(SOCKET_ADDRESS_LIST* pAddressList,
 	size_t addrlen = 0, size;
 	UINT8 *offset;
 
-	if (m_pWvProvider == NULL) {
-		return ND_INSUFFICIENT_RESOURCES;
-	}
-
 	hr = getaddrinfo("..localmachine", NULL, NULL, &res);
 	if (hr) {
 		goto out;
@@ -199,12 +214,7 @@ CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppObject)
 		return E_NOINTERFACE;
 	}
 
-	*ppObject = new CNDProvider();
-	if (*ppObject == NULL) {
-		return E_OUTOFMEMORY;
-	}
-
-	return S_OK;
+	return CNDProvider::CreateInstance((CNDProvider **) ppObject);
 }
 
 STDMETHODIMP CNDClassFactory::
diff --git a/trunk/ulp/netdirect2/user/nd_provider.h b/trunk/ulp/netdirect2/user/nd_provider.h
index b0e3709..0c38d8e 100644
--- a/trunk/ulp/netdirect2/user/nd_provider.h
+++ b/trunk/ulp/netdirect2/user/nd_provider.h
@@ -53,11 +53,41 @@ public:
 
 	CNDProvider();
 	~CNDProvider();
+
 	void Delete() {delete this;}
+	static STDMETHODIMP
+	CreateInstance(CNDProvider **ppProvider)
+	{
+		HRESULT hr;
+		CNDProvider *provider;
+
+		provider = new CNDProvider();
+		if (provider == NULL) {
+			hr = ND_NO_MEMORY;
+			goto err1;
+		}
+
+		hr = provider->Init();
+		if (FAILED(hr)) {
+			goto err2;
+		}
+
+		*ppProvider = provider;
+		return ND_SUCCESS;
+
+	err2:
+		provider->Release();
+	err1:
+		*ppProvider = NULL;
+		return hr;
+	}
 
 	STDMETHODIMP QueryAdapterAddressList(SOCKET_ADDRESS_LIST* pAddressList,
 										 SIZE_T* pcbAddressList, UINT64 adapterId);
 	IWVProvider *m_pWvProvider;
+
+private:
+	STDMETHODIMP Init();
 };
 
 




More information about the ofw mailing list