summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-08-05 12:33:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-08-05 12:33:51 +0000
commit5b87649397d756384a6b4897a2907fbeec6ccaa5 (patch)
treeb914edac7f6c4eae3b3aa70be8e58d03afc5b7b4 /src/mir_app
parent8074aab3090c5699e41a8bc219dfb07e7e782790 (diff)
additional fix for the case of parallel destruction
git-svn-id: http://svn.miranda-ng.org/main/trunk@17161 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/netlib.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 0dab252161..0cbc7dd450 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -270,34 +270,34 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
break;
case NLH_CONNECTION:
+ WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
{
NetlibConnection *nlc = (NetlibConnection*)wParam;
-
- WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
- if (nlc->usingHttpGateway)
- HttpGatewayRemovePacket(nlc, -1);
- else {
- if (nlc->s != INVALID_SOCKET)
- NetlibDoClose(nlc, nlc->termRequested);
- if (nlc->s2 != INVALID_SOCKET)
- closesocket(nlc->s2);
- nlc->s2 = INVALID_SOCKET;
- }
- ReleaseMutex(hConnectionHeaderMutex);
-
- HANDLE waitHandles[4] = { hConnectionHeaderMutex, nlc->hOkToCloseEvent, nlc->ncsRecv.hMutex, nlc->ncsSend.hMutex };
- DWORD waitResult = WaitForMultipleObjects(_countof(waitHandles), waitHandles, TRUE, INFINITE);
- if (waitResult >= WAIT_OBJECT_0 + _countof(waitHandles)) {
+ if (GetNetlibHandleType(nlc) == NLH_CONNECTION) {
+ if (nlc->usingHttpGateway)
+ HttpGatewayRemovePacket(nlc, -1);
+ else {
+ if (nlc->s != INVALID_SOCKET)
+ NetlibDoClose(nlc, nlc->termRequested);
+ if (nlc->s2 != INVALID_SOCKET)
+ closesocket(nlc->s2);
+ nlc->s2 = INVALID_SOCKET;
+ }
ReleaseMutex(hConnectionHeaderMutex);
- SetLastError(ERROR_INVALID_PARAMETER); //already been closed
- return 0;
- }
- NetlibLogf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
- delete nlc;
+ HANDLE waitHandles[4] = { hConnectionHeaderMutex, nlc->hOkToCloseEvent, nlc->ncsRecv.hMutex, nlc->ncsSend.hMutex };
+ DWORD waitResult = WaitForMultipleObjects(_countof(waitHandles), waitHandles, TRUE, INFINITE);
+ if (waitResult >= WAIT_OBJECT_0 + _countof(waitHandles)) {
+ ReleaseMutex(hConnectionHeaderMutex);
+ SetLastError(ERROR_INVALID_PARAMETER); //already been closed
+ return 0;
+ }
- ReleaseMutex(hConnectionHeaderMutex);
+ NetlibLogf(nlc->nlu, "(%p:%u) Connection closed", nlc, nlc->s);
+ delete nlc;
+ }
}
+ ReleaseMutex(hConnectionHeaderMutex);
return 1;
case NLH_BOUNDPORT: