winverbs: fixes to support OFED compatibility libraries and ND
[mirror/winof/.git] / core / winverbs / kernel / wv_ep.c
index fa7942d..ee89253 100644 (file)
@@ -501,25 +501,26 @@ void WvEpConnect(WV_PROVIDER *pProvider, WDFREQUEST Request)
        WdfObjectAcquireLock(ep->Queue);\r
        if (ep->State != WvEpRouteResolved) {\r
                status = STATUS_NOT_SUPPORTED;\r
-               goto release;\r
+               goto unlock;\r
        }\r
 \r
        status = IbCmInterface.CM.create_id(WvEpIbCmHandler, ep, &ep->pIbCmId);\r
        if (!NT_SUCCESS(status)) {\r
-               goto release;\r
+               goto unlock;\r
        }\r
 \r
        ep->State = WvEpActiveConnect;\r
-       status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
+       status = IbCmInterface.CM.send_req(ep->pIbCmId, &req);\r
        if (NT_SUCCESS(status)) {\r
-               status = IbCmInterface.CM.send_req(ep->pIbCmId, &req);\r
+               status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
        }\r
 \r
        if (!NT_SUCCESS(status)) {\r
                ep->State = WvEpDisconnected;\r
        }\r
-release:\r
+unlock:\r
        WdfObjectReleaseLock(ep->Queue);\r
+release:\r
        WvEpRelease(ep);\r
 complete:\r
        if (!NT_SUCCESS(status)) {\r
@@ -618,9 +619,7 @@ static NTSTATUS WvEpAcceptActive(WDFREQUEST Request, UINT8 *pVerbsData, size_t V
        pEndpoint->State = WvEpConnected;\r
        status = IbCmInterface.CM.send_rtu(pEndpoint->pIbCmId, pAttr->Param.Data,\r
                                                                           pAttr->Param.DataLength);\r
-       if (NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, STATUS_SUCCESS);\r
-       } else {\r
+       if (!NT_SUCCESS(status)) {\r
                pEndpoint->State = WvEpDisconnected;\r
        }\r
 \r
@@ -722,6 +721,10 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request)
                break;\r
        case WvEpPassiveConnect:\r
                status = WvEpAcceptPassive(Request, out, outlen, ep, pattr);\r
+               if (NT_SUCCESS(status)) {\r
+                       WvEpRelease(ep);\r
+                       return;\r
+               }\r
                break;\r
        default:\r
                status = STATUS_NOT_SUPPORTED;\r
@@ -730,9 +733,7 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request)
 \r
        WvEpRelease(ep);\r
 complete:\r
-       if (!NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, status);\r
-       }\r
+       WdfRequestComplete(Request, status);\r
 }\r
 \r
 void WvEpReject(WV_PROVIDER *pProvider, WDFREQUEST Request)\r
@@ -831,6 +832,11 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request)
        case WvEpConnected:\r
        case WvEpActiveDisconnect:\r
                status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
+               if (NT_SUCCESS(status)) {\r
+                       WdfObjectReleaseLock(ep->Queue);\r
+                       WvEpRelease(ep);\r
+                       return;\r
+               }\r
                break;\r
        case WvEpPassiveDisconnect:\r
        case WvEpDisconnected:\r
@@ -844,9 +850,7 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request)
 \r
        WvEpRelease(ep);\r
 complete:\r
-       if (!NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, status);\r
-       }\r
+       WdfRequestComplete(Request, status);\r
 }\r
 \r
 static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent)\r
@@ -864,6 +868,7 @@ static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent)
                goto release;\r
        }\r
 \r
+       ASSERT(!IsListEmpty(&listen->Entry));\r
        ep = CONTAINING_RECORD(RemoveHeadList(&listen->Entry), WV_ENDPOINT, Entry);\r
        ep->pIbCmId = pId;\r
        pId->callback = WvEpIbCmHandler;\r