Closing a socket while in listening state (that has not accepted any connections) no longer certainly crashes the system. There's still a tendency to crash the system sometimes, but it's related to possibly not canceling any outstanding IRPs for the listening socket.

svn path=/branches/GSoC_2011/TcpIpDriver/; revision=51962
This commit is contained in:
Claudiu Mihail 2011-05-27 19:37:28 +00:00
parent 350d378e7f
commit 04c4235e97

View file

@ -83,7 +83,8 @@ NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog )
} }
BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener, BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
PCONNECTION_ENDPOINT Connection ) { PCONNECTION_ENDPOINT Connection )
{
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
PTDI_BUCKET Bucket; PTDI_BUCKET Bucket;
KIRQL OldIrql; KIRQL OldIrql;
@ -92,10 +93,12 @@ BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
LockObject(Listener, &OldIrql); LockObject(Listener, &OldIrql);
ListEntry = Listener->ListenRequest.Flink; ListEntry = Listener->ListenRequest.Flink;
while ( ListEntry != &Listener->ListenRequest ) { while ( ListEntry != &Listener->ListenRequest )
{
Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry); Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
if( Bucket->AssociatedEndpoint == Connection ) { if( Bucket->AssociatedEndpoint == Connection )
{
DereferenceObject(Bucket->AssociatedEndpoint); DereferenceObject(Bucket->AssociatedEndpoint);
RemoveEntryList( &Bucket->Entry ); RemoveEntryList( &Bucket->Entry );
ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG ); ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG );
@ -131,6 +134,8 @@ NTSTATUS TCPAccept ( PTDI_REQUEST Request,
if( Bucket ) if( Bucket )
{ {
Bucket->AssociatedEndpoint = Connection; Bucket->AssociatedEndpoint = Connection;
ReferenceObject(Bucket->AssociatedEndpoint);
Bucket->Request.RequestNotifyObject = Complete; Bucket->Request.RequestNotifyObject = Complete;
Bucket->Request.RequestContext = Context; Bucket->Request.RequestContext = Context;
InsertTailList( &Listener->ListenRequest, &Bucket->Entry ); InsertTailList( &Listener->ListenRequest, &Bucket->Entry );