[ros-diffs] [cmihail] 52894: [lwIP/TCPIP] - Fix completing IRPs with 0 bytes received when getting the data from the connection's packet queue - Eliminate memory leaks caused by unreleased pbufs - Get rid of s...

cmihail at svn.reactos.org cmihail at svn.reactos.org
Tue Jul 26 11:25:25 UTC 2011


Author: cmihail
Date: Tue Jul 26 11:25:24 2011
New Revision: 52894

URL: http://svn.reactos.org/svn/reactos?rev=52894&view=rev
Log:
[lwIP/TCPIP]
- Fix completing IRPs with 0 bytes received when getting the data from the connection's packet queue
- Eliminate memory leaks caused by unreleased pbufs
- Get rid of some commented code

In principle the speed issue with lwIP should be pretty much solved now. There's still some minor things to iron out that testing will reveal probably. Initial tests like running opera, downloading stuff etc seem to be very encouraging however.

Modified:
    branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c
    branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
    branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c

Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c?rev=52894&r1=52893&r2=52894&view=diff
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Tue Jul 26 11:25:24 2011
@@ -46,7 +46,6 @@
     ExFreePoolWithTag(Bucket, TDI_BUCKET_TAG);
 }
 
-static
 VOID
 CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous)
 {
@@ -149,22 +148,10 @@
     DbgPrint("[IP, TCPFinEventHandler] Called for Connection( 0x%x )-> SocketContext = pcb (0x%x)\n", Connection, Connection->SocketContext);
 
     /* Only clear the pointer if the shutdown was caused by an error */
-    if ((err != ERR_OK))// && (status != STATUS_REMOTE_DISCONNECT))
+    if ((err != ERR_OK))
     {
         /* We're already closed by the error so we don't want to call lwip_close */
         DbgPrint("[IP, TCPFinEventHandler] MAKING Connection( 0x%x )-> SocketContext = pcb (0x%x) NULL\n", Connection, Connection->SocketContext);
-
-        // close all possible callbacks
-        /*tcp_arg((PTCP_PCB)Connection->SocketContext, NULL);
-
-        if (((PTCP_PCB)Connection->SocketContext)->state != LISTEN)
-        {
-            tcp_recv((PTCP_PCB)Connection->SocketContext, NULL);
-            tcp_sent((PTCP_PCB)Connection->SocketContext, NULL);
-            tcp_err((PTCP_PCB)Connection->SocketContext, NULL);
-        }
-
-        tcp_accept((PTCP_PCB)Connection->SocketContext, NULL);*/
 
         Connection->SocketContext = NULL;
     }

Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c?rev=52894&r1=52893&r2=52894&view=diff
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Tue Jul 26 11:25:24 2011
@@ -428,7 +428,7 @@
     
         /* Freed in TCPSocketState */
         Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket), TDI_BUCKET_TAG );
-        if( !Bucket )
+        if (!Bucket)
         {
             TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Failed to allocate bucket\n"));
             UnlockObject(Connection, OldIrql);
@@ -438,20 +438,25 @@
     
         Bucket->Request.RequestNotifyObject = Complete;
         Bucket->Request.RequestContext = Context;
-        *BytesReceived = 0;
-    
+
         InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry );
         TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Queued read irp\n"));
 
         UnlockObject(Connection, OldIrql);
 
         TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Leaving. Status = STATUS_PENDING\n"));
+
+        (*BytesReceived) = 0;
+    }
+    else
+    {
+        (*BytesReceived) = Received;
     }
 
     DbgPrint("[IP, TCPReceiveData] Leaving. Status = %s\n",
         Status == STATUS_PENDING? "STATUS_PENDING" : "STATUS_SUCCESS");
 
-    return STATUS_PENDING;
+    return Status;
 }
 
 NTSTATUS TCPSendData

Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c?rev=52894&r1=52893&r2=52894&view=diff
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Tue Jul 26 11:25:24 2011
@@ -47,7 +47,7 @@
         qp = CONTAINING_RECORD(Entry, QUEUE_ENTRY, ListEntry);
         
         // reenable this later
-        //pbuf_free(qp->p);
+        pbuf_free(qp->p);
 
         ExFreePoolWithTag(qp, LWIP_TAG);
     }
@@ -92,7 +92,7 @@
 
         RecvLen = MIN(p->tot_len, RecvLen);
 
-        for ((*Received) = 0; (*Received) < RecvLen; *Received += p->len, p = p->next)
+        for ((*Received) = 0; (*Received) < RecvLen; (*Received) += p->len, p = p->next)
         {
             DbgPrint("[lwIP, LibTCPGetDataFromConnectionQueue] 0x%x: Copying %d bytes to 0x%x from 0x%x\n",
                 p, p->len, ((PUCHAR)RecvBuffer) + (*Received), p->payload);
@@ -101,7 +101,7 @@
         }
 
         // reenable this later
-        //pbuf_free(qp->p);
+        pbuf_free(qp->p);
         ExFreePoolWithTag(qp, LWIP_TAG);
 
         Status = STATUS_SUCCESS;




More information about the Ros-diffs mailing list