winebus.sys: Only keep a single read pending.
The design of hidclass.sys prevents any concurrent irps, there's no need to queue more. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51824 Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bbcee5c23d
commit
bd780ba618
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
|
@ -74,7 +75,7 @@ struct device_extension
|
|||
DWORD last_report_size;
|
||||
BOOL last_report_read;
|
||||
DWORD buffer_size;
|
||||
LIST_ENTRY irp_queue;
|
||||
IRP *pending_read;
|
||||
|
||||
struct unix_device *unix_device;
|
||||
};
|
||||
|
@ -249,17 +250,28 @@ static WCHAR *get_compatible_ids(DEVICE_OBJECT *device)
|
|||
return dst;
|
||||
}
|
||||
|
||||
static IRP *pop_pending_read(struct device_extension *ext)
|
||||
{
|
||||
IRP *pending;
|
||||
|
||||
RtlEnterCriticalSection(&ext->cs);
|
||||
pending = ext->pending_read;
|
||||
ext->pending_read = NULL;
|
||||
RtlLeaveCriticalSection(&ext->cs);
|
||||
|
||||
return pending;
|
||||
}
|
||||
|
||||
static void remove_pending_irps(DEVICE_OBJECT *device)
|
||||
{
|
||||
struct device_extension *ext = device->DeviceExtension;
|
||||
LIST_ENTRY *entry;
|
||||
IRP *pending;
|
||||
|
||||
while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue)
|
||||
if ((pending = pop_pending_read(ext)))
|
||||
{
|
||||
IRP *queued_irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
|
||||
queued_irp->IoStatus.Status = STATUS_DELETE_PENDING;
|
||||
queued_irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(queued_irp, IO_NO_INCREMENT);
|
||||
pending->IoStatus.Status = STATUS_DELETE_PENDING;
|
||||
pending->IoStatus.Information = 0;
|
||||
IoCompleteRequest(pending, IO_NO_INCREMENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,7 +307,6 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni
|
|||
ext->buffer_size = 0;
|
||||
ext->unix_device = unix_device;
|
||||
|
||||
InitializeListHead(&ext->irp_queue);
|
||||
InitializeCriticalSection(&ext->cs);
|
||||
ext->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs");
|
||||
|
||||
|
@ -398,9 +409,10 @@ static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_l
|
|||
|
||||
static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
|
||||
{
|
||||
struct device_extension *ext = (struct device_extension*)device->DeviceExtension;
|
||||
struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
|
||||
IO_STACK_LOCATION *stack;
|
||||
ULONG buffer_len;
|
||||
IRP *irp;
|
||||
LIST_ENTRY *entry;
|
||||
|
||||
if (!length || !report)
|
||||
return;
|
||||
|
@ -427,15 +439,11 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length
|
|||
ext->last_report_size = length;
|
||||
ext->last_report_read = FALSE;
|
||||
|
||||
while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue)
|
||||
if ((irp = pop_pending_read(ext)))
|
||||
{
|
||||
IO_STACK_LOCATION *irpsp;
|
||||
TRACE_(hid_report)("Processing Request\n");
|
||||
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
|
||||
irpsp = IoGetCurrentIrpStackLocation(irp);
|
||||
irp->IoStatus.Status = deliver_last_report(ext,
|
||||
irpsp->Parameters.DeviceIoControl.OutputBufferLength,
|
||||
irp->UserBuffer, &irp->IoStatus.Information);
|
||||
stack = IoGetCurrentIrpStackLocation(irp);
|
||||
buffer_len = stack->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
irp->IoStatus.Status = deliver_last_report(ext, buffer_len, irp->UserBuffer, &irp->IoStatus.Information);
|
||||
ext->last_report_read = TRUE;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
}
|
||||
|
@ -1015,7 +1023,10 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
|
|||
}
|
||||
else
|
||||
{
|
||||
InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.ListEntry);
|
||||
/* hidclass.sys should guarantee this */
|
||||
assert(!ext->pending_read);
|
||||
ext->pending_read = irp;
|
||||
IoMarkIrpPending(irp);
|
||||
irp->IoStatus.Status = STATUS_PENDING;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue