Author: cmihail Date: Fri Jun 17 13:39:28 2011 New Revision: 52313
URL: http://svn.reactos.org/svn/reactos?rev=52313&view=rev Log: [IP] Fix memory leak caused by socket context overwriting when accepting a new connection.
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.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/driver... ============================================================================== --- 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] Fri Jun 17 13:39:28 2011 @@ -48,6 +48,13 @@
static VOID +SocketContextCloseWorker(PVOID Context) +{ + LibTCPClose(Context); +} + +static +VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous) { ReferenceObject(Connection); @@ -96,6 +103,7 @@ Bucket->Status = Status; Bucket->Information = 0;
+ //DereferenceObject(Bucket->AssociatedEndpoint); CompleteBucket(Connection, Bucket, TRUE); }
@@ -146,6 +154,7 @@ PIRP Irp; NTSTATUS Status; KIRQL OldIrql; + void *OldSocketContext;
DbgPrint("[IP, TCPAcceptEventHandler] Called\n");
@@ -183,6 +192,10 @@ newpcb->identifier);
LockObject(Bucket->AssociatedEndpoint, &OldIrql); + + /* free previously created socket context (we don't use it, we use newpcb) */ + //LibTCPClose(Bucket->AssociatedEndpoint->SocketContext); + OldSocketContext = Bucket->AssociatedEndpoint->SocketContext; Bucket->AssociatedEndpoint->SocketContext = newpcb;
LibTCPAccept(newpcb, @@ -199,6 +212,10 @@ }
DereferenceObject(Connection); + + /* free socket context created in FileOpenConnection, as we're using a new + one; we free it asynchornously because otherwise we create a dedlock */ + ChewCreate(SocketContextCloseWorker, OldSocketContext); }
VOID