Merge pull request #1758 from awakecoding/master

Bulk Decompression Fix
This commit is contained in:
Marc-André Moreau 2014-03-26 09:24:16 -04:00
commit 60981532f6
4 changed files with 35 additions and 21 deletions

View File

@ -434,15 +434,16 @@ static void* drive_hotplug_thread_func(void* arg)
struct timeval tv;
int rv;
rdpdr = (rdpdrPlugin *)arg;
rdpdr = (rdpdrPlugin*) arg;
rdpdr->stop_event = CreateEvent(NULL, TRUE, FALSE, NULL);
rdpdr->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
mfd = open("/proc/mounts", O_RDONLY, 0);
if (mfd < 0)
{
fprintf(stderr, "ERROR: Unable to open /proc/mounts.");
return NULL;
fprintf(stderr, "ERROR: Unable to open /proc/mounts.");
return NULL;
}
FD_ZERO(&rfds);
@ -452,7 +453,7 @@ static void* drive_hotplug_thread_func(void* arg)
while ((rv = select(mfd+1, NULL, NULL, &rfds, &tv)) >= 0)
{
if (WaitForSingleObject(rdpdr->stop_event, 0) == WAIT_OBJECT_0)
if (WaitForSingleObject(rdpdr->stopEvent, 0) == WAIT_OBJECT_0)
break;
if (FD_ISSET(mfd, &rfds))
@ -467,13 +468,19 @@ static void* drive_hotplug_thread_func(void* arg)
tv.tv_usec = 0;
}
return NULL;
return NULL;
}
static void drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr)
{
if (rdpdr->stop_event)
SetEvent(rdpdr->stop_event);
if (rdpdr->hotplugThread)
{
if (rdpdr->stopEvent)
SetEvent(rdpdr->stopEvent);
WaitForSingleObject(rdpdr->hotplugThread, INFINITE);
rdpdr->hotplugThread = NULL;
}
}
#endif
@ -493,11 +500,14 @@ static void rdpdr_process_connect(rdpdrPlugin* rdpdr)
for (index = 0; index < settings->DeviceCount; index++)
{
device = settings->DeviceArray[index];
if (strcmp(device->Name, "*") == 0)
if (device->Name && (strcmp(device->Name, "*") == 0))
{
rdpdr->hotplug_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)drive_hotplug_thread_func, rdpdr, 0, NULL);
rdpdr->hotplugThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) drive_hotplug_thread_func, rdpdr, 0, NULL);
continue;
}
devman_load_device_service(rdpdr->devman, device);
}
}
@ -939,8 +949,6 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
drive_hotplug_thread_terminate(rdpdr);
WaitForSingleObject(rdpdr->hotplug_thread, INFINITE);
rdpdr->channelEntryPoints.pVirtualChannelClose(rdpdr->OpenHandle);
if (rdpdr->data_in)

View File

@ -54,11 +54,11 @@ struct rdpdr_plugin
char computerName[256];
/* hotplug support */
HANDLE hotplug_thread;
HANDLE hotplugThread;
#ifdef _WIN32
HWND hotplug_wnd;
#else
HANDLE stop_event;
HANDLE stopEvent;
#endif
};

View File

@ -77,7 +77,7 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD
{
*ppDstData = pSrcData;
*pDstSize = SrcSize;
status = 1;
status = 0;
}
if (status >= 0)

View File

@ -337,6 +337,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
rdpRdp* rdp;
int next_pos;
wStream* cs;
int bulkStatus;
UINT32 totalSize;
BYTE updateCode;
BYTE fragmentation;
@ -365,8 +366,18 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
cs = s;
next_pos = Stream_GetPosition(s) + size;
if (bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags))
bulkStatus = bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags);
if (bulkStatus < 0)
{
fprintf(stderr, "bulk_decompress() failed\n");
return -1;
}
if (bulkStatus > 0)
{
/* data was compressed, copy from decompression buffer */
size = DstSize;
cs = StreamPool_Take(transport->ReceivePool, DstSize);
@ -375,11 +386,6 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
Stream_SealLength(cs);
Stream_SetPosition(cs, 0);
}
else
{
fprintf(stderr, "bulk_decompress() failed\n");
Stream_Seek(s, size);
}
if (fragmentation == FASTPATH_FRAGMENT_SINGLE)
{