[SERIAL] Immediately complete read IRP if all requested bytes have been found in...
authorHervé Poussineau <hpoussin@reactos.org>
Thu, 2 May 2019 11:26:46 +0000 (13:26 +0200)
committerHervé Poussineau <hpoussin@reactos.org>
Thu, 2 May 2019 18:06:47 +0000 (20:06 +0200)
Previously, we had to wait to receive another byte to finish the first IRP.

drivers/serial/serial/rw.c

index df101ca..4179ac8 100644 (file)
@@ -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))
                {