[AFD]
authorThomas Faber <thomas.faber@reactos.org>
Sun, 14 Jun 2015 07:54:19 +0000 (07:54 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 14 Jun 2015 07:54:19 +0000 (07:54 +0000)
- Don't leave the IRP queued if TdiSendDatagram does not perform its downcall. Complete it instead.
CORE-9810

svn path=/trunk/; revision=68130

reactos/drivers/network/afd/afd/write.c

index 9350cf3..27f9150 100644 (file)
@@ -379,13 +379,23 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
             Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND);
             if (Status == STATUS_PENDING)
             {
-                TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
-                                FCB->AddressFile.Object,
-                                SendReq->BufferArray[0].buf,
-                                SendReq->BufferArray[0].len,
-                                TargetAddress,
-                                PacketSocketSendComplete,
-                                FCB);
+                Status = TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
+                                         FCB->AddressFile.Object,
+                                         SendReq->BufferArray[0].buf,
+                                         SendReq->BufferArray[0].len,
+                                         TargetAddress,
+                                         PacketSocketSendComplete,
+                                         FCB);
+                if (Status != STATUS_PENDING)
+                {
+                    NT_VERIFY(RemoveHeadList(&FCB->PendingIrpList[FUNCTION_SEND]) == &Irp->Tail.Overlay.ListEntry);
+                    Irp->IoStatus.Status = Status;
+                    Irp->IoStatus.Information = 0;
+                    (void)IoSetCancelRoutine(Irp, NULL);
+                    UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
+                    UnlockRequest(Irp, IoGetCurrentIrpStackLocation(Irp));
+                    IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
+                }
             }
 
             ExFreePool( TargetAddress );
@@ -631,13 +641,23 @@ AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
         Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND);
         if (Status == STATUS_PENDING)
         {
-            TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
-                            FCB->AddressFile.Object,
-                            SendReq->BufferArray[0].buf,
-                            SendReq->BufferArray[0].len,
-                            TargetAddress,
-                            PacketSocketSendComplete,
-                            FCB);
+            Status = TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
+                                     FCB->AddressFile.Object,
+                                     SendReq->BufferArray[0].buf,
+                                     SendReq->BufferArray[0].len,
+                                     TargetAddress,
+                                     PacketSocketSendComplete,
+                                     FCB);
+            if (Status != STATUS_PENDING)
+            {
+                NT_VERIFY(RemoveHeadList(&FCB->PendingIrpList[FUNCTION_SEND]) == &Irp->Tail.Overlay.ListEntry);
+                Irp->IoStatus.Status = Status;
+                Irp->IoStatus.Information = 0;
+                (void)IoSetCancelRoutine(Irp, NULL);
+                UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
+                UnlockRequest(Irp, IoGetCurrentIrpStackLocation(Irp));
+                IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
+            }
         }
 
         ExFreePool(TargetAddress);