From 470dbb5304566c15be2c5e3c7c486a18b20ec740 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 5 Aug 2013 07:50:11 -0700 Subject: [PATCH] oops: still remove address from set tracked if it's not tcp --- xwords4/relay/cref.cpp | 8 ++++---- xwords4/relay/tpool.cpp | 35 ++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/xwords4/relay/cref.cpp b/xwords4/relay/cref.cpp index 2d53d5b24..4133f12fe 100644 --- a/xwords4/relay/cref.cpp +++ b/xwords4/relay/cref.cpp @@ -419,14 +419,14 @@ CookieRef::removeSocket( const AddrInfo* addr ) { RWWriteLock rwl( &m_socketsRWLock ); vector::iterator iter; - for ( iter = m_sockets.begin(); !found && iter != m_sockets.end(); ++iter ) { + for ( iter = m_sockets.begin(); !found && iter != m_sockets.end(); + ++iter ) { if ( iter->m_addr.equals( *addr ) ) { if ( iter->m_ackPending ) { logf( XW_LOGINFO, "%s: Never got ack; removing hid %d from DB", __func__, iter->m_hostID ); - DBMgr::Get()->RmDeviceByHid( ConnName(), - iter->m_hostID ); + DBMgr::Get()->RmDeviceByHid( ConnName(), iter->m_hostID ); m_nPlayersHere -= iter->m_nPlayersH; cancelAckTimer( iter->m_hostID ); } @@ -831,7 +831,7 @@ CookieRef::send_with_length( const AddrInfo* addr, HostID dest, failed = true; } - if ( failed && cascade && addr->isTCP() ) { + if ( failed && cascade ) { pushRemoveSocketEvent( addr ); XWThreadPool::GetTPool()->CloseSocket( addr ); } diff --git a/xwords4/relay/tpool.cpp b/xwords4/relay/tpool.cpp index 369129a1d..36a866cc6 100644 --- a/xwords4/relay/tpool.cpp +++ b/xwords4/relay/tpool.cpp @@ -173,26 +173,27 @@ XWThreadPool::RemoveSocket( const AddrInfo* addr ) void XWThreadPool::CloseSocket( const AddrInfo* addr ) { - assert( addr->isTCP() ); - if ( !RemoveSocket( addr ) ) { - MutexLock ml( &m_queueMutex ); - deque::iterator iter = m_queue.begin(); - while ( iter != m_queue.end() ) { - if ( iter->m_info.m_addr.equals( *addr ) ) { - m_queue.erase( iter ); - break; + if ( addr->isTCP() ) { + if ( !RemoveSocket( addr ) ) { + MutexLock ml( &m_queueMutex ); + deque::iterator iter = m_queue.begin(); + while ( iter != m_queue.end() ) { + if ( iter->m_info.m_addr.equals( *addr ) ) { + m_queue.erase( iter ); + break; + } + ++iter; } - ++iter; } - } - logf( XW_LOGINFO, "CLOSING socket %d", addr->socket() ); - close( addr->socket() ); + logf( XW_LOGINFO, "CLOSING socket %d", addr->socket() ); + close( addr->socket() ); - /* We always need to interrupt the poll because the socket we're closing - will be in the list being listened to. That or we need to drop sockets - that have been removed on some other thread while the poll call's - blocking.*/ - interrupt_poll(); + /* We always need to interrupt the poll because the socket we're closing + will be in the list being listened to. That or we need to drop sockets + that have been removed on some other thread while the poll call's + blocking.*/ + interrupt_poll(); + } } void