We need to return all MADs to IBAL before calling close_al. To protect
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 6 May 2009 06:06:21 +0000 (06:06 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 6 May 2009 06:06:21 +0000 (06:06 +0000)
against queuing MADs during deregistration, set the MAD service handle
to NULL when deregistering and check that it is still valid before queuing
any received MADs.

This fixes a hanging when using ctrl-C to kill a process running ibping.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2152 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/winmad/kernel/wm_provider.c
core/winmad/kernel/wm_provider.h
core/winmad/kernel/wm_reg.c

index 2970c88..56df62f 100644 (file)
@@ -92,11 +92,13 @@ static ib_mad_element_t *WmRemoveMad(WM_PROVIDER *pProvider)
        return mad;\r
 }\r
 \r
-void WmProviderFlushReceives(WM_PROVIDER *pProvider, WM_REGISTRATION *pRegistration)\r
+void WmProviderDeregister(WM_PROVIDER *pProvider, WM_REGISTRATION *pRegistration)\r
 {\r
        ib_mad_element_t        *mad, *next, *list;\r
 \r
        WdfObjectAcquireLock(pProvider->ReadQueue);\r
+       pRegistration->hService = NULL;\r
+\r
        list = pProvider->MadHead;\r
        pProvider->MadHead = NULL;\r
 \r
@@ -372,20 +374,24 @@ void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,
        size_t                  len = 0;\r
 \r
        UNREFERENCED_PARAMETER(hService);\r
+       reg = (WM_REGISTRATION *) pMad->send_context1;\r
 \r
        WdfObjectAcquireLock(prov->ReadQueue);\r
+       if (reg->hService == NULL) {\r
+               reg->pDevice->IbInterface.put_mad(pMad);\r
+               goto unlock;\r
+       }\r
+       \r
        status = WdfIoQueueRetrieveNextRequest(prov->ReadQueue, &request);\r
        if (!NT_SUCCESS(status)) {\r
                WmInsertMad(prov, pMad);\r
-               WdfObjectReleaseLock(prov->ReadQueue);\r
-               return;\r
+               goto unlock;\r
        }\r
 \r
        status = WdfRequestRetrieveOutputBuffer(request, sizeof(WM_IO_MAD), &wmad, &len);\r
        if (!NT_SUCCESS(status)) {\r
-               reg = (WM_REGISTRATION *) pMad->send_context1;\r
                reg->pDevice->IbInterface.put_mad(pMad);\r
-               goto out;\r
+               goto complete;\r
        }\r
 \r
        status = WmCopyRead(prov, wmad, pMad, &len);\r
@@ -395,10 +401,11 @@ void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,
        } else {\r
                WmInsertMad(prov, pMad);\r
        }\r
-       WdfObjectReleaseLock(prov->ReadQueue);\r
 \r
-out:\r
-       WdfRequestCompleteWithInformation(request, status, len);        \r
+complete:\r
+       WdfRequestCompleteWithInformation(request, status, len);\r
+unlock:\r
+       WdfObjectReleaseLock(prov->ReadQueue);\r
 }\r
 \r
 void WmSendHandler(ib_mad_svc_handle_t hService, void *Context,\r
index d35b87f..3088f3d 100644 (file)
@@ -75,8 +75,8 @@ void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,
                                          ib_mad_element_t *pMad);\r
 void WmSendHandler(ib_mad_svc_handle_t hService, void *Context,\r
                                   ib_mad_element_t *pMad);\r
-void WmProviderFlushReceives(WM_PROVIDER *pProvider,\r
-                                                        struct _WM_REGISTRATION *pRegistration);\r
+void WmProviderDeregister(WM_PROVIDER *pProvider,\r
+                                                 struct _WM_REGISTRATION *pRegistration);\r
 void WmProviderCancel(WM_PROVIDER *pProvider, WDFREQUEST Request);\r
 \r
 #endif // _WM_PROVIDER_H_\r
index 94d6191..22c0211 100644 (file)
@@ -274,12 +274,12 @@ void WmRegRemoveHandler(WM_REGISTRATION *pRegistration)
                return;\r
        }\r
 \r
+       WmProviderDeregister(pRegistration->pProvider, pRegistration);\r
        pRegistration->pDevice->IbInterface.destroy_qp(pRegistration->hQp, NULL);\r
        pRegistration->pDevice->IbInterface.dealloc_pd(pRegistration->hPd, NULL);\r
        pRegistration->pDevice->IbInterface.close_ca(pRegistration->hCa, NULL);\r
        pRegistration->pDevice->IbInterface.close_al(pRegistration->hIbal);\r
 \r
-       WmProviderFlushReceives(pRegistration->pProvider, pRegistration);\r
        WmIbDevicePut(pRegistration->pDevice);\r
        pRegistration->pDevice = NULL;\r
 }\r