From 06c8fdc67fd866ece1b246b1c4437f76a82088d0 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 16 Sep 2010 01:13:26 -0700 Subject: [PATCH] stop tracking seeds separately until have a use for 'em separate from HostRec. This fixes failure to reconnect so that now a complete game is possible (gtk version) without the two devices every being connected at the same time. --- xwords4/relay/cref.cpp | 45 ++++----------------------------------- xwords4/relay/cref.h | 1 - xwords4/relay/crefmgr.cpp | 1 + 3 files changed, 5 insertions(+), 42 deletions(-) diff --git a/xwords4/relay/cref.cpp b/xwords4/relay/cref.cpp index 3ba566f14..4aace3d42 100644 --- a/xwords4/relay/cref.cpp +++ b/xwords4/relay/cref.cpp @@ -209,7 +209,9 @@ void CookieRef::_Reconnect( int socket, HostID hid, int nPlayersH, int nPlayersS, int seed ) { - if ( !AlreadyHere( seed, socket ) ) { + if ( AlreadyHere( seed, socket ) ) { + logf( XW_LOGINFO, "dropping [re]connection because already here" ); + } else { (void)CRefMgr::Get()->Associate( socket, this ); pushReconnectEvent( socket, hid, nPlayersH, nPlayersS, seed ); handleEvents(); @@ -311,12 +313,8 @@ bool CookieRef::AlreadyHere( unsigned short seed, int socket ) { bool here = false; - vector::iterator iter; - for ( iter = m_seeds.begin(); !here && iter != m_seeds.end(); ++iter ) { - here = *iter == seed; - } - if ( !here && socket != -1 ) { + if ( socket != -1 ) { vector::const_iterator iter; for ( iter = m_sockets.begin(); !here && iter != m_sockets.end(); ++iter ) { @@ -811,7 +809,6 @@ CookieRef::increasePlayerCounts( const CRefEvent* evt, bool reconn ) m_sockets.push_back( hr ); assert( !AlreadyHere( evt->u.con.seed, -1 ) ); - m_seeds.push_back( evt->u.con.seed ); logf( XW_LOGVERBOSE1, "%s: here=%d; total=%d", __func__, m_nPlayersHere, m_nPlayersSought ); @@ -853,40 +850,6 @@ CookieRef::postCheckAllHere() m_eventQueue.push_back( evt ); } -/* bool */ -/* CookieRef::socketAlreadyHere( int socket ) */ -/* { */ -/* ASSERT_LOCKED(); */ -/* bool found = false; */ -/* vector::const_iterator iter; */ -/* for ( iter = m_sockets.begin(); iter != m_sockets.end(); ++iter ) { */ -/* if ( iter->m_seed == seed && iter->m_socket == socket ) { */ -/* found = true; */ -/* break; */ -/* } */ -/* } */ -/* return found; */ -/* } */ - -void -CookieRef::reducePlayerCounts( int socket ) -{ - logf( XW_LOGVERBOSE1, "%s(socket=%d)", __func__, socket ); - ASSERT_LOCKED(); - vector::iterator iter; - for ( iter = m_sockets.begin(); iter != m_sockets.end(); ++iter ) { - if ( iter->m_socket == socket ) { - m_nPlayersHere -= iter->m_nPlayersH; - - logf( XW_LOGVERBOSE1, - "%s: m_nPlayersHere=%d; m_nPlayersSought=%d", - __func__, m_nPlayersHere, m_nPlayersSought ); - - break; - } - } -} /* reducePlayerCounts */ - void CookieRef::setAllConnectedTimer() { diff --git a/xwords4/relay/cref.h b/xwords4/relay/cref.h index 6f72fcf0b..c855f62b0 100644 --- a/xwords4/relay/cref.h +++ b/xwords4/relay/cref.h @@ -281,7 +281,6 @@ class CookieRef { pthread_t m_locking_thread; /* for debugging only */ bool m_in_handleEvents; /* for debugging only */ int m_delayMicros; - vector m_seeds; }; /* CookieRef */ #endif diff --git a/xwords4/relay/crefmgr.cpp b/xwords4/relay/crefmgr.cpp index d765899a9..869994e50 100644 --- a/xwords4/relay/crefmgr.cpp +++ b/xwords4/relay/crefmgr.cpp @@ -264,6 +264,7 @@ CRefMgr::getMakeCookieRef_locked( const char* cookie, HostID hid, int socket, return cref; } /* getMakeCookieRef_locked */ +/* reconnect case */ CookieRef* CRefMgr::getMakeCookieRef_locked( const char* connName, HostID hid, int socket, int nPlayersH, int seed )