From 95772d3ad158a81faa0051f1a8f471657a5701f9 Mon Sep 17 00:00:00 2001 From: ehouse Date: Mon, 21 Mar 2005 05:30:12 +0000 Subject: [PATCH] remove null-dereference when socket closed by two threads --- relay/cref.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/relay/cref.cpp b/relay/cref.cpp index ff25fe0a9..ddbcc416b 100644 --- a/relay/cref.cpp +++ b/relay/cref.cpp @@ -91,15 +91,19 @@ void RemoveSocketRefs( int socket ) { CookieRef* cref = getCookieRefForSocket( socket ); - cref->Remove( socket ); + if ( cref != NULL ) { + cref->Remove( socket ); - SocketMap::iterator iter = gSocketStuff.find( socket ); - assert( iter != gSocketStuff.end() ); - gSocketStuff.erase( iter ); + SocketMap::iterator iter = gSocketStuff.find( socket ); + assert( iter != gSocketStuff.end() ); + gSocketStuff.erase( iter ); - if ( cref->CountSockets() == 0 ) { - ForgetCref( cref ); - delete cref; + if ( cref->CountSockets() == 0 ) { + ForgetCref( cref ); + delete cref; + } + } else { + logf( "socket already dead" ); } }