fix crash on client reset

This commit is contained in:
David Rose 2003-12-03 17:07:32 +00:00
parent 92e51ab336
commit 19364486e7
2 changed files with 16 additions and 7 deletions

View File

@ -114,10 +114,18 @@ poll() {
_listener->poll(); _listener->poll();
Readers::const_iterator ri; Readers::const_iterator ri = _readers.begin();
for (ri = _readers.begin(); ri != _readers.end(); ++ri) { while (ri != _readers.end()) {
(*ri).second->poll(); // Preincrement the iterator, in case we remove it as a result of
(*ri).second->idle(); // calling poll().
Readers::const_iterator rnext = ri;
++rnext;
PStatReader *reader = (*ri).second;
reader->poll();
reader->idle();
ri = rnext;
} }
} }
@ -224,7 +232,7 @@ is_thread_safe() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: PStatServer::connection_reset // Function: PStatServer::connection_reset
// Access: Private // Access: Protected, Virtual
// Description: Called when a lost connection is detected by the net // Description: Called when a lost connection is detected by the net
// code, this should pass the word on to the interested // code, this should pass the word on to the interested
// parties and clean up gracefully. // parties and clean up gracefully.
@ -243,7 +251,7 @@ connection_reset(const PT(Connection) &connection, PRErrorCode errcode) {
// Unfortunately, we can't delete the reader right away, because // Unfortunately, we can't delete the reader right away, because
// we might have been called from a method on the reader! We'll // we might have been called from a method on the reader! We'll
// have to safe the reader pointer and delete it some time later. // have to save the reader pointer and delete it some time later.
_lost_readers.push_back(reader); _lost_readers.push_back(reader);
} }
} }

View File

@ -63,10 +63,11 @@ public:
virtual bool is_thread_safe(); virtual bool is_thread_safe();
private: protected:
virtual void connection_reset(const PT(Connection) &connection, virtual void connection_reset(const PT(Connection) &connection,
PRErrorCode errcode); PRErrorCode errcode);
private:
PStatListener *_listener; PStatListener *_listener;
typedef pmap<PT(Connection), PStatReader *> Readers; typedef pmap<PT(Connection), PStatReader *> Readers;