https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bef39dd62ee62a2b7c0eb…
commit bef39dd62ee62a2b7c0eb1a3749dee0c700b5188
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Thu May 2 13:26:46 2019 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Thu May 2 20:06:47 2019 +0200
[SERIAL] Immediately complete read IRP if all requested bytes have been found in
circular buffer
Previously, we had to wait to receive another byte to finish the first IRP.
---
drivers/serial/serial/rw.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial/rw.c b/drivers/serial/serial/rw.c
index df101ca07b..4179ac820b 100644
--- a/drivers/serial/serial/rw.c
+++ b/drivers/serial/serial/rw.c
@@ -65,7 +65,7 @@ ReadBytes(
}
/* while buffer is not fully filled */
- while (Length > 0)
+ while (TRUE)
{
/* read already received bytes from buffer */
KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql);
@@ -81,6 +81,12 @@ ReadBytes(
KeClearEvent(&DeviceExtension->InputBufferNotEmpty);
KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql);
+ if (Length == 0)
+ {
+ INFO_(SERIAL, "All bytes read\n");
+ break;
+ }
+
if (WorkItemData->DontWait
&& !(WorkItemData->ReadAtLeastOneByte && Information == 0))
{