[AFD] Introduce and use pool tags. Thanks go to Arty for assisting me with this....
[reactos.git] / drivers / network / afd / afd / read.c
index 935379e..b0ff01a 100644 (file)
@@ -153,7 +153,7 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
     PIRP NextIrp;
     PIO_STACK_LOCATION NextIrpSp;
     PAFD_RECV_INFO RecvReq;
-    UINT TotalBytesCopied = 0, RetBytesCopied = 0;
+    UINT TotalBytesCopied = 0;
     NTSTATUS Status = STATUS_SUCCESS, RetStatus = STATUS_PENDING;
 
     AFD_DbgPrint(MID_TRACE,("%p %p\n", FCB, Irp));
@@ -182,7 +182,7 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
             }
             else
             {
-                /* Unexpected disconnect by the remote host or initial read after a graceful disconnnect */
+                /* Unexpected disconnect by the remote host or initial read after a graceful disconnect */
                 Status = FCB->LastReceiveStatus;
             }
             NextIrp->IoStatus.Status = Status;
@@ -227,7 +227,6 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
                 NextIrp->IoStatus.Information = TotalBytesCopied;
                 if( NextIrp == Irp ) {
                     RetStatus = Status;
-                    RetBytesCopied = TotalBytesCopied;
                 }
                 if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
                 (void)IoSetCancelRoutine(NextIrp, NULL);
@@ -264,12 +263,6 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
 
     AFD_DbgPrint(MID_TRACE,("RetStatus for irp %p is %x\n", Irp, RetStatus));
 
-    /* Sometimes we're called with a NULL Irp */
-    if( Irp ) {
-        Irp->IoStatus.Status = RetStatus;
-        Irp->IoStatus.Information = RetBytesCopied;
-    }
-
     return RetStatus;
 }
 
@@ -416,8 +409,8 @@ SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp,
     if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK))
     {
         FCB->Recv.Content -= DatagramRecv->Len;
-        ExFreePool( DatagramRecv->Address );
-        ExFreePool( DatagramRecv );
+        ExFreePoolWithTag(DatagramRecv->Address, TAG_AFD_TRANSPORT_ADDRESS);
+        ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM);
     }
 
     AFD_DbgPrint(MID_TRACE,("Done\n"));
@@ -591,8 +584,8 @@ PacketSocketRecvComplete(
         while( !IsListEmpty( &FCB->DatagramList ) ) {
                DatagramRecvEntry = RemoveHeadList(&FCB->DatagramList);
                DatagramRecv = CONTAINING_RECORD(DatagramRecvEntry, AFD_STORED_DATAGRAM, ListEntry);
-               ExFreePool( DatagramRecv->Address );
-               ExFreePool( DatagramRecv );
+               ExFreePoolWithTag(DatagramRecv->Address, TAG_AFD_TRANSPORT_ADDRESS);
+               ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM);
         }
 
         SocketStateUnlock( FCB );
@@ -611,7 +604,9 @@ PacketSocketRecvComplete(
         return STATUS_FILE_CLOSED;
     }
 
-    DatagramRecv = ExAllocatePool( NonPagedPool, DGSize );
+    DatagramRecv = ExAllocatePoolWithTag(NonPagedPool,
+                                         DGSize,
+                                         TAG_AFD_STORED_DATAGRAM);
 
     if( DatagramRecv ) {
         DatagramRecv->Len = Irp->IoStatus.Information;
@@ -627,7 +622,12 @@ PacketSocketRecvComplete(
     } else Status = STATUS_NO_MEMORY;
 
     if( !NT_SUCCESS( Status ) ) {
-        if( DatagramRecv ) ExFreePool( DatagramRecv );
+
+        if (DatagramRecv)
+        {
+            ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM);
+        }
+
         SocketStateUnlock( FCB );
         return Status;
     } else {