[ofw] [PATCH] nd2: simplify ND provider creation
Fab Tillier
ftillier at microsoft.com
Tue Jul 27 18:22:23 PDT 2010
Looks good to me (LGTM)
-Fab
Hefty, Sean wrote on Tue, 27 Jul 2010 at 16:51:34
> nd2: simplify ND provider creation
>
> From: Sean Hefty <sean.hefty at intel.com>
>
> Remove the CNDClassFactory implementation and instead create
> ND provider objects directly in DllGetClassObject().
>
> Signed-off-by: Sean Hefty <sean.hefty at intel.com>
> ---
> trunk/ulp/netdirect2/user/nd_main.cpp | 9 +----
> trunk/ulp/netdirect2/user/nd_provider.cpp | 55 +----------------------------
> trunk/ulp/netdirect2/user/nd_provider.h | 21 +----------
> 3 files changed, 6 insertions(+), 79 deletions(-)
>
> diff --git a/trunk/ulp/netdirect2/user/nd_main.cpp b/trunk/ulp/netdirect2/user/nd_main.cpp
> index 1b9e049..e995d60 100644
> --- a/trunk/ulp/netdirect2/user/nd_main.cpp
> +++ b/trunk/ulp/netdirect2/user/nd_main.cpp
> @@ -72,17 +72,12 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
> {
> UNREFERENCED_PARAMETER(rclsid);
>
> - if (riid != IID_IClassFactory) {
> + if (riid != IID_INDProvider) {
> *ppv = NULL;
> return E_NOINTERFACE;
> }
>
> - *ppv = new CNDClassFactory();
> - if (*ppv == NULL) {
> - return E_OUTOFMEMORY;
> - }
> -
> - return S_OK;
> + return CNDProvider::CreateInstance(ppv);
> }
>
> int WSPStartup(WORD wVersionRequested, LPWSPDATA lpWSPData,
> diff --git a/trunk/ulp/netdirect2/user/nd_provider.cpp b/trunk/ulp/netdirect2/user/nd_provider.cpp
> index cbc9c22..37362f7 100644
> --- a/trunk/ulp/netdirect2/user/nd_provider.cpp
> +++ b/trunk/ulp/netdirect2/user/nd_provider.cpp
> @@ -1,5 +1,6 @@
> /*
> * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.
> + * Copyright (c) 2010 Microsoft Corporation. All rights reserved.
> *
> * This software is available to you under the OpenIB.org BSD license
> * below:
> @@ -64,7 +65,7 @@ CNDProvider::~CNDProvider()
> if (m_pWvProvider) {
> m_pWvProvider->Release();
> }
> - InterlockedDecrement(&m_gRef);
> + InterlockedDecrement(&g_nRef);
> }
>
> STDMETHODIMP CNDProvider::
> @@ -176,55 +177,3 @@ OpenAdapter(REFIID iid, UINT64 adapterId, VOID** ppAdapter)
>
> return CNDAdapter::CreateInstance(this, adapterId, ppAdapter);
> }
> -
> -
> -//-------------------------
> -// CNDClassFactory routines
> -//-------------------------
> -
> -STDMETHODIMP CNDClassFactory::
> -QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
> -{
> - if (riid != IID_IUnknown && riid != IID_IClassFactory) {
> - *ppvObj = NULL;
> - return E_NOINTERFACE;
> - }
> -
> - *ppvObj = this;
> - AddRef();
> - return ND_SUCCESS;
> -}
> -
> -STDMETHODIMP_(ULONG) CNDClassFactory::
> -AddRef(void)
> -{
> - return CNDBase::AddRef();
> -}
> -
> -STDMETHODIMP_(ULONG) CNDClassFactory::
> -Release(void)
> -{
> - return CNDBase::Release();
> -}
> -
> -STDMETHODIMP CNDClassFactory::
> -CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppObject)
> -{
> - if (pUnkOuter != NULL) {
> - return CLASS_E_NOAGGREGATION;
> - }
> -
> - if (riid != IID_INDProvider) {
> - *ppObject = NULL;
> - return E_NOINTERFACE;
> - }
> -
> - return CNDProvider::CreateInstance((CNDProvider **) ppObject);
> -}
> -
> -STDMETHODIMP CNDClassFactory::
> -LockServer(BOOL fLock)
> -{
> - UNREFERENCED_PARAMETER(fLock);
> - return S_OK;
> -}
> diff --git a/trunk/ulp/netdirect2/user/nd_provider.h b/trunk/ulp/netdirect2/user/nd_provider.h
> index 0c38d8e..10d3900 100644
> --- a/trunk/ulp/netdirect2/user/nd_provider.h
> +++ b/trunk/ulp/netdirect2/user/nd_provider.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.
> + * Copyright (c) 2010 Microsoft Corporation. All rights reserved.
> *
> * This software is available to you under the OpenIB.org BSD license
> * below:
> @@ -56,7 +57,7 @@ public:
>
> void Delete() {delete this;}
> static STDMETHODIMP
> - CreateInstance(CNDProvider **ppProvider)
> + CreateInstance(VOID** ppProvider)
> {
> HRESULT hr;
> CNDProvider *provider;
> @@ -90,22 +91,4 @@ private:
> STDMETHODIMP Init();
> };
>
> -
> -class CNDClassFactory : public IClassFactory, public CNDBase
> -{
> -public:
> - // IUnknown methods
> - STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
> - STDMETHODIMP_(ULONG) AddRef();
> - STDMETHODIMP_(ULONG) Release();
> -
> - // IClassFactory methods
> - STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppObject);
> - STDMETHODIMP LockServer(BOOL fLock);
> -
> - CNDClassFactory() {};
> - ~CNDClassFactory() {};
> - void Delete() {delete this;}
> -};
> -
> #endif // _ND_PROVIDER_H_
> \ No newline at end of file
>
>
> _______________________________________________
> ofw mailing list
> ofw at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
>
>
More information about the ofw
mailing list