Clean up drdynvc channels porperly locked.

(cherry picked from commit 7f1cca78aa)
This commit is contained in:
akallabeth 2020-11-06 13:38:47 +01:00 committed by akallabeth
parent 0615135c24
commit 7bec222d85
1 changed files with 14 additions and 6 deletions

View File

@ -1400,15 +1400,23 @@ static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
/* Disconnect remaining dynamic channels that the server did not. /* Disconnect remaining dynamic channels that the server did not.
* This is required to properly shut down channels by calling the appropriate * This is required to properly shut down channels by calling the appropriate
* event handlers. */ * event handlers. */
size_t count = 0;
DVCMAN* drdynvcMgr = (DVCMAN*)drdynvc->channel_mgr; DVCMAN* drdynvcMgr = (DVCMAN*)drdynvc->channel_mgr;
while (ArrayList_Count(drdynvcMgr->channels) > 0) do
{
ArrayList_Lock(drdynvcMgr->channels);
count = ArrayList_Count(drdynvcMgr->channels);
if (count > 0)
{ {
IWTSVirtualChannel* channel = IWTSVirtualChannel* channel =
(IWTSVirtualChannel*)ArrayList_GetItem(drdynvcMgr->channels, 0); (IWTSVirtualChannel*)ArrayList_GetItem(drdynvcMgr->channels, 0);
const UINT32 ChannelId = drdynvc->channel_mgr->GetChannelId(channel); const UINT32 ChannelId = drdynvc->channel_mgr->GetChannelId(channel);
dvcman_close_channel(drdynvc->channel_mgr, ChannelId, FALSE); dvcman_close_channel(drdynvc->channel_mgr, ChannelId, FALSE);
count--;
} }
ArrayList_Unlock(drdynvcMgr->channels);
} while (count > 0);
} }
if (error && drdynvc->rdpcontext) if (error && drdynvc->rdpcontext)