mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
remove null-dereference when socket closed by two threads
This commit is contained in:
parent
94df6e022c
commit
95772d3ad1
1 changed files with 11 additions and 7 deletions
|
@ -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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue