librdmacm: fix event reporting when destroying listen
[mirror/winof/.git] / etc / user / comp_channel.cpp
index 613189a..14849bd 100644 (file)
@@ -230,7 +230,8 @@ static COMP_ENTRY *CompChannelFindRemove(COMP_CHANNEL *pChannel, COMP_ENTRY *pEn
                entry_ptr = &(*entry_ptr)->Next;\r
        }\r
 \r
-       if (*entry_ptr != NULL) {\r
+       entry = *entry_ptr;\r
+       if (entry != NULL) {\r
                *entry_ptr = pEntry->Next;\r
                if (pChannel->TailPtr == &pEntry->Next) {\r
                        pChannel->TailPtr = entry_ptr;\r
@@ -239,7 +240,7 @@ static COMP_ENTRY *CompChannelFindRemove(COMP_CHANNEL *pChannel, COMP_ENTRY *pEn
                InterlockedExchange(&pEntry->Busy, 0);\r
        }\r
        LeaveCriticalSection(&pChannel->Lock);\r
-       return *entry_ptr;\r
+       return entry;\r
 }\r
 \r
 static void CompChannelQueue(COMP_CHANNEL *pChannel, COMP_ENTRY *pEntry)\r
@@ -311,10 +312,13 @@ DWORD CompEntryPost(COMP_ENTRY *pEntry)
        return 0;\r
 }\r
 \r
-void CompEntryCancel(COMP_ENTRY *pEntry)\r
+COMP_ENTRY *CompEntryCancel(COMP_ENTRY *pEntry)\r
 {\r
+       COMP_ENTRY *entry = NULL;\r
+\r
        while (pEntry->Busy) {\r
                Sleep(0);\r
-               CompChannelFindRemove(pEntry->Channel, pEntry);\r
+               entry = CompChannelFindRemove(pEntry->Channel, pEntry);\r
        }\r
+       return entry;\r
 }\r