From 23f9b3bbc05fe78b5db635b8d1513bb824281fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 8 Jul 2015 11:17:56 -0400 Subject: [PATCH] channels/rdpgfx: reset state on channel close --- channels/rdpgfx/client/rdpgfx_main.c | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index bed2f61ba..6d6ab10fd 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -886,12 +886,62 @@ static int rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback) static int rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) { + int count; + int index; + ULONG_PTR* pKeys = NULL; RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback; + RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; + RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; WLog_DBG(TAG, "OnClose"); free(callback); + gfx->UnacknowledgedFrames = 0; + gfx->TotalDecodedFrames = 0; + + if (gfx->zgfx) + { + zgfx_context_free(gfx->zgfx); + gfx->zgfx = zgfx_context_new(FALSE); + + if (!gfx->zgfx) + return -1; + } + + count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys); + + for (index = 0; index < count; index++) + { + RDPGFX_DELETE_SURFACE_PDU pdu; + + pdu.surfaceId = ((UINT16) pKeys[index]) - 1; + + if (context && context->DeleteSurface) + { + context->DeleteSurface(context, &pdu); + } + } + + free(pKeys); + + for (index = 0; index < gfx->MaxCacheSlot; index++) + { + if (gfx->CacheSlots[index]) + { + RDPGFX_EVICT_CACHE_ENTRY_PDU pdu; + + pdu.cacheSlot = (UINT16) index; + + if (context && context->EvictCacheEntry) + { + context->EvictCacheEntry(context, &pdu); + } + + gfx->CacheSlots[index] = NULL; + } + } + return 0; }