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:
ehouse 2009-11-09 05:30:42 +00:00
parent 393cccb86c
commit 2ecf415618
2 changed files with 8 additions and 1 deletions

View file

@ -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;

View file

@ -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