mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +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_starttime = uptime();
|
||||||
m_gameFull = false;
|
m_gameFull = false;
|
||||||
m_nHostMsgs = 0;
|
m_nHostMsgs = 0;
|
||||||
|
m_in_handleEvents = false;
|
||||||
|
|
||||||
RelayConfigs::GetConfigs()->GetValueFor( "HEARTBEAT", &m_heatbeat );
|
RelayConfigs::GetConfigs()->GetValueFor( "HEARTBEAT", &m_heatbeat );
|
||||||
logf( XW_LOGINFO, "initing cref for cookie %s, connName %s",
|
logf( XW_LOGINFO, "initing cref for cookie %s, connName %s",
|
||||||
|
@ -489,6 +490,9 @@ CookieRef::pushLastSocketGoneEvent()
|
||||||
void
|
void
|
||||||
CookieRef::handleEvents()
|
CookieRef::handleEvents()
|
||||||
{
|
{
|
||||||
|
assert( !m_in_handleEvents );
|
||||||
|
m_in_handleEvents = true;
|
||||||
|
|
||||||
/* Assumption: has mutex!!!! */
|
/* Assumption: has mutex!!!! */
|
||||||
while ( m_eventQueue.size () > 0 ) {
|
while ( m_eventQueue.size () > 0 ) {
|
||||||
XW_RELAY_STATE nextState;
|
XW_RELAY_STATE nextState;
|
||||||
|
@ -573,6 +577,7 @@ CookieRef::handleEvents()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XWA_NOTE_EMPTY:
|
case XWA_NOTE_EMPTY:
|
||||||
|
cancelAllConnectedTimer();
|
||||||
if ( 0 == count_msgs_stored() ) {
|
if ( 0 == count_msgs_stored() ) {
|
||||||
CRefEvent evt;
|
CRefEvent evt;
|
||||||
evt.type = XWE_NOMOREMSGS;
|
evt.type = XWE_NOMOREMSGS;
|
||||||
|
@ -598,6 +603,7 @@ CookieRef::handleEvents()
|
||||||
m_curState = nextState;
|
m_curState = nextState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_in_handleEvents = false;
|
||||||
} /* handleEvents */
|
} /* handleEvents */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -612,7 +618,7 @@ CookieRef::send_with_length( int socket, unsigned char* buf, int bufLen,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( failed && cascade ) {
|
if ( failed && cascade ) {
|
||||||
_Remove( socket );
|
pushRemoveSocketEvent( socket );
|
||||||
XWThreadPool::GetTPool()->CloseSocket( socket );
|
XWThreadPool::GetTPool()->CloseSocket( socket );
|
||||||
}
|
}
|
||||||
return !failed;
|
return !failed;
|
||||||
|
|
|
@ -257,6 +257,7 @@ class CookieRef {
|
||||||
pthread_mutex_t m_mutex;
|
pthread_mutex_t m_mutex;
|
||||||
|
|
||||||
pthread_t m_locking_thread; /* for debugging only */
|
pthread_t m_locking_thread; /* for debugging only */
|
||||||
|
bool m_in_handleEvents; /* for debugging only */
|
||||||
}; /* CookieRef */
|
}; /* CookieRef */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue