From 61993fc0790753b677ef3750b055ae4edf1bc782 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 26 Feb 2018 07:03:47 -0800 Subject: [PATCH] add tests to the rest of the forever loops --- xwords4/relay/crefmgr.cpp | 17 ++++++++++++++--- xwords4/relay/xwrelay.cpp | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/xwords4/relay/crefmgr.cpp b/xwords4/relay/crefmgr.cpp index faa36a000..c3d76202e 100644 --- a/xwords4/relay/crefmgr.cpp +++ b/xwords4/relay/crefmgr.cpp @@ -239,7 +239,8 @@ CRefMgr::getMakeCookieRef( const char* cookie, int nPlayersH, int nPlayersT, no cref. So we test for that case and retry. */ /* I'm now seeing an infinte loop here. Until it's tracked down, let's - assert out. */ + assert out. Note that I've seen it here, not at any of the other + places where I'm replacing FOREVER loops with this test*/ if ( ii > 5 ) { assert(0); break; @@ -358,7 +359,12 @@ CRefMgr::getMakeCookieRef( const char* const connName, HostID hid, bool* isDead int nPlayersT = 0; int nAlreadyHere = 0; - for ( ; ; ) { /* for: see comment above */ + for ( int ii = 0; ; ++ii ) { /* for: see comment above */ + if ( ii > 5 ) { + assert(0); + break; + } + CookieID cid = m_db->FindGame( connName, hid, curCookie, sizeof(curCookie), &curLangCode, &nPlayersT, &nAlreadyHere, isDead ); @@ -397,7 +403,12 @@ CRefMgr::getMakeCookieRef( const AddrInfo::ClientToken clientToken, HostID srcID int nPlayersT = 0; int nAlreadyHere = 0; - for ( ; ; ) { /* for: see comment above */ + for ( int ii = 0; ; ++ii ) { /* for: see comment above */ + if ( ii > 5 ) { + assert(0); + break; + } + char connName[MAX_CONNNAME_LEN+1] = {0}; CookieID cid = m_db->FindGame( clientToken, srcID, connName, sizeof(connName), diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index e94fd7666..b91e4320c 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -1802,8 +1802,8 @@ handle_udp_packet( PacketThreadClosure* ptc ) handlePutMessage( scr, hid, &addr, end - ptr, &ptr, end ); assert( ptr == end ); // DON'T CHECK THIS IN!!! } else { - logf( XW_LOGERROR, "%s: invalid scr for %s", __func__, - connName ); + logf( XW_LOGERROR, "%s: invalid scr for %s/%d", __func__, + connName, hid ); } } else { logf( XW_LOGERROR, "no clientToken found!!!" );