mirror of
https://github.com/reactos/reactos.git
synced 2024-09-13 06:11:59 +00:00
[IP]
Fix memory leak caused by socket context overwriting when accepting a new connection. svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52313
This commit is contained in:
parent
f08a479325
commit
c2770feda9
|
@ -46,6 +46,13 @@ BucketCompletionWorker(PVOID Context)
|
|||
DereferenceObject(Bucket->AssociatedEndpoint);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
SocketContextCloseWorker(PVOID Context)
|
||||
{
|
||||
LibTCPClose(Context);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous)
|
||||
|
@ -96,6 +103,7 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
|||
Bucket->Status = Status;
|
||||
Bucket->Information = 0;
|
||||
|
||||
//DereferenceObject(Bucket->AssociatedEndpoint);
|
||||
CompleteBucket(Connection, Bucket, TRUE);
|
||||
}
|
||||
|
||||
|
@ -146,6 +154,7 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
|||
PIRP Irp;
|
||||
NTSTATUS Status;
|
||||
KIRQL OldIrql;
|
||||
void *OldSocketContext;
|
||||
|
||||
DbgPrint("[IP, TCPAcceptEventHandler] Called\n");
|
||||
|
||||
|
@ -183,6 +192,10 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
|||
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 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
|||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue