mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 18:00:41 +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
1 changed files with 17 additions and 0 deletions
|
@ -46,6 +46,13 @@ BucketCompletionWorker(PVOID Context)
|
||||||
DereferenceObject(Bucket->AssociatedEndpoint);
|
DereferenceObject(Bucket->AssociatedEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
SocketContextCloseWorker(PVOID Context)
|
||||||
|
{
|
||||||
|
LibTCPClose(Context);
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous)
|
CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous)
|
||||||
|
@ -96,6 +103,7 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
||||||
Bucket->Status = Status;
|
Bucket->Status = Status;
|
||||||
Bucket->Information = 0;
|
Bucket->Information = 0;
|
||||||
|
|
||||||
|
//DereferenceObject(Bucket->AssociatedEndpoint);
|
||||||
CompleteBucket(Connection, Bucket, TRUE);
|
CompleteBucket(Connection, Bucket, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +154,7 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
void *OldSocketContext;
|
||||||
|
|
||||||
DbgPrint("[IP, TCPAcceptEventHandler] Called\n");
|
DbgPrint("[IP, TCPAcceptEventHandler] Called\n");
|
||||||
|
|
||||||
|
@ -183,6 +192,10 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
||||||
newpcb->identifier);
|
newpcb->identifier);
|
||||||
|
|
||||||
LockObject(Bucket->AssociatedEndpoint, &OldIrql);
|
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;
|
Bucket->AssociatedEndpoint->SocketContext = newpcb;
|
||||||
|
|
||||||
LibTCPAccept(newpcb,
|
LibTCPAccept(newpcb,
|
||||||
|
@ -199,6 +212,10 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
||||||
}
|
}
|
||||||
|
|
||||||
DereferenceObject(Connection);
|
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
|
VOID
|
||||||
|
|
Loading…
Reference in a new issue