mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
Remove on case where HandleEvents was being called recursively and
creating unexpected state transitions; add assert to catch any future recursion.
This commit is contained in:
parent
393cccb86c
commit
2ecf415618
2 changed files with 8 additions and 1 deletions
|
@ -94,6 +94,7 @@ CookieRef::ReInit( const char* cookie, const char* connName, CookieID id )
|
|||
m_starttime = uptime();
|
||||
m_gameFull = false;
|
||||
m_nHostMsgs = 0;
|
||||
m_in_handleEvents = false;
|
||||
|
||||
RelayConfigs::GetConfigs()->GetValueFor( "HEARTBEAT", &m_heatbeat );
|
||||
logf( XW_LOGINFO, "initing cref for cookie %s, connName %s",
|
||||
|
@ -489,6 +490,9 @@ CookieRef::pushLastSocketGoneEvent()
|
|||
void
|
||||
CookieRef::handleEvents()
|
||||
{
|
||||
assert( !m_in_handleEvents );
|
||||
m_in_handleEvents = true;
|
||||
|
||||
/* Assumption: has mutex!!!! */
|
||||
while ( m_eventQueue.size () > 0 ) {
|
||||
XW_RELAY_STATE nextState;
|
||||
|
@ -573,6 +577,7 @@ CookieRef::handleEvents()
|
|||
break;
|
||||
|
||||
case XWA_NOTE_EMPTY:
|
||||
cancelAllConnectedTimer();
|
||||
if ( 0 == count_msgs_stored() ) {
|
||||
CRefEvent evt;
|
||||
evt.type = XWE_NOMOREMSGS;
|
||||
|
@ -598,6 +603,7 @@ CookieRef::handleEvents()
|
|||
m_curState = nextState;
|
||||
}
|
||||
}
|
||||
m_in_handleEvents = false;
|
||||
} /* handleEvents */
|
||||
|
||||
bool
|
||||
|
@ -612,7 +618,7 @@ CookieRef::send_with_length( int socket, unsigned char* buf, int bufLen,
|
|||
}
|
||||
|
||||
if ( failed && cascade ) {
|
||||
_Remove( socket );
|
||||
pushRemoveSocketEvent( socket );
|
||||
XWThreadPool::GetTPool()->CloseSocket( socket );
|
||||
}
|
||||
return !failed;
|
||||
|
|
|
@ -257,6 +257,7 @@ class CookieRef {
|
|||
pthread_mutex_t m_mutex;
|
||||
|
||||
pthread_t m_locking_thread; /* for debugging only */
|
||||
bool m_in_handleEvents; /* for debugging only */
|
||||
}; /* CookieRef */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue