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:
Claudiu Mihail 2011-06-17 13:39:28 +00:00
parent f08a479325
commit c2770feda9

View file

@ -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