Removed stream cleanup stream. Now the engine is using an iterator to terminate all streams at cleanup.

git-svn-id: http://voip.null.ro/svn/yate@1729 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2008-02-14 13:11:14 +00:00
parent 8062d574b2
commit 1133f1238e
3 changed files with 5 additions and 15 deletions

View File

@ -402,10 +402,11 @@ void JBEngine::initialize(const NamedList& params)
void JBEngine::cleanup()
{
Lock lock(this);
for (ObjList* o = m_streams.skipNull(); o; o = o->skipNext()) {
JBStream* s = static_cast<JBStream*>(o->get());
// Use an iterator: the stream might be destroyed when terminating
ListIterator iter(m_streams);
for (GenObject* o = 0; 0 != (o = iter.get());) {
JBStream* s = static_cast<JBStream*>(o);
s->terminate(true,0,XMPPError::Shutdown,0,true);
s->cleanup();
}
}

View File

@ -475,6 +475,7 @@ void JBStream::terminate(bool destroy, XMLElement* recvStanza, XMPPError::Type e
const char* reason, bool send, bool final)
{
Lock2 lock(m_socket.m_streamMutex,m_socket.m_receiveMutex);
TelEngine::destruct(m_startEvent);
if (state() == Destroy) {
if (recvStanza)
delete recvStanza;
@ -520,7 +521,6 @@ void JBStream::terminate(bool destroy, XMLElement* recvStanza, XMPPError::Type e
// Cancel all outgoing elements without id
removePending(false,0,true);
// Always set termination event, except when exiting
TelEngine::destruct(m_startEvent);
if (!(m_terminateEvent || m_engine->exiting())) {
if (!recvStanza && error != XMPPError::NoError)
recvStanza = XMPPUtils::createStreamError(error,reason);

View File

@ -475,17 +475,6 @@ public:
removePending(notify,&id,false);
}
/**
* Cleanup the stream before destroying
* This method is thread safe
*/
inline void cleanup() {
Lock lock(m_socket.m_streamMutex);
m_events.clear();
TelEngine::destruct(m_terminateEvent);
TelEngine::destruct(m_startEvent);
}
/**
* Get the name of a stream state
* @param state The requested state number