Fixed stream reconnection procedure.
Wait for an answer when a subscribe request is forcibly sent before call. git-svn-id: http://voip.null.ro/svn/yate@1085 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
0831be8c62
commit
9d0ac08bca
|
@ -11,6 +11,9 @@
|
|||
; xmlparser_maxbuffer: integer: Maximum length of text we ever parse as XML
|
||||
;xmlparser_maxbuffer=8192
|
||||
|
||||
; stream_partialrestart: integer: Number of quick Jabber stream connect attempts
|
||||
;stream_partialrestart=2
|
||||
|
||||
; stream_partialrestart: integer: Number of failures between 2 successfull Jabber
|
||||
; stream connect attempts, -1 to keep trying
|
||||
;stream_partialrestart=-1
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace TelEngine;
|
|||
*/
|
||||
|
||||
// Default values
|
||||
#define JB_STREAM_PARTIALRESTART -1
|
||||
#define JB_STREAM_PARTIALRESTART 2
|
||||
#define JB_STREAM_TOTALRESTART -1
|
||||
|
||||
// Sleep time for threads
|
||||
|
@ -63,6 +63,9 @@ void JBEngine::initialize(const NamedList& params)
|
|||
// Stream restart attempts
|
||||
m_partialStreamRestart =
|
||||
params.getIntValue("stream_partialrestart",JB_STREAM_PARTIALRESTART);
|
||||
// sanity check to avoid perpetual retries
|
||||
if (m_partialStreamRestart < 1)
|
||||
m_partialStreamRestart = 1;
|
||||
m_totalStreamRestart =
|
||||
params.getIntValue("stream_totalrestart",JB_STREAM_TOTALRESTART);
|
||||
// XML parser max receive buffer
|
||||
|
@ -107,7 +110,7 @@ JBComponentStream* JBEngine::getStream(const char* domain)
|
|||
domain = m_componentDomain;
|
||||
JBComponentStream* stream = findStream(domain);
|
||||
XDebug(this,DebugAll,
|
||||
"getStream. Remote: '%s'. Stream exists: %s",domain,stream?"YES":"NO");
|
||||
"getStream. Remote: '%s'. Stream exists: %s (%p)",domain,stream?"YES":"NO",stream);
|
||||
if (!stream) {
|
||||
SocketAddr addr(PF_INET);
|
||||
addr.host(domain);
|
||||
|
|
|
@ -50,7 +50,7 @@ JBComponentStream::JBComponentStream(JBEngine* engine, const String& remoteName,
|
|||
m_receiveMutex(true),
|
||||
m_lastEvent(0),
|
||||
m_terminateEvent(0),
|
||||
m_partialRestart(-1),
|
||||
m_partialRestart(2),
|
||||
m_totalRestart(-1),
|
||||
m_waitBeforeConnect(false)
|
||||
{
|
||||
|
@ -149,6 +149,8 @@ void JBComponentStream::terminate(bool destroy, bool sendEnd,
|
|||
Lock2 lock(*this,m_receiveMutex);
|
||||
if (m_state == Destroy || m_state == Terminated)
|
||||
return;
|
||||
DDebug(m_engine,DebugAll,"JBComponentStream::terminate(%s, %s, %p, %s) [%p]",
|
||||
String::boolText(destroy),String::boolText(sendEnd),error,String::boolText(sendError),this);
|
||||
// Error is sent only if end stream is sent
|
||||
XMLElement* eventError = 0;
|
||||
if (sendEnd && sendError) {
|
||||
|
@ -167,7 +169,7 @@ void JBComponentStream::terminate(bool destroy, bool sendEnd,
|
|||
}
|
||||
else {
|
||||
addEvent(JBEvent::Terminated,eventError);
|
||||
m_state = Destroy;
|
||||
m_state = Terminated;
|
||||
}
|
||||
Debug(m_engine,DebugAll,"Stream. %s. [%p]",destroy?"Destroy":"Terminate",this);
|
||||
}
|
||||
|
@ -297,6 +299,8 @@ void JBComponentStream::cleanup(bool endStream, XMLElement* e)
|
|||
delete e;
|
||||
return;
|
||||
}
|
||||
DDebug(m_engine,DebugAll,"Stream::cleanup(%s, %p) [%p]",
|
||||
String::boolText(endStream),e,this);
|
||||
bool partialData = false;
|
||||
// Remove first element from queue if partial data was sent
|
||||
ObjList* obj = m_outXML.skipNull();
|
||||
|
@ -758,7 +762,7 @@ bool JBComponentStream::readSocket(char* data, u_int32_t& len)
|
|||
#ifdef XDEBUG
|
||||
if (len) {
|
||||
String s(data,len);
|
||||
XDebug(m_engine,DebugAll,"Stream::readSocket [%p]\r\nData: %s",s.c_str(),this);
|
||||
XDebug(m_engine,DebugAll,"Stream::readSocket [%p] Data:\r\n%s",this,s.c_str());
|
||||
}
|
||||
#endif //XDEBUG
|
||||
return true;
|
||||
|
@ -774,7 +778,7 @@ bool JBComponentStream::writeSocket(const char* data, u_int32_t& len)
|
|||
return false;
|
||||
}
|
||||
// Write data
|
||||
XDebug(m_engine,DebugAll,"Stream::writeSocket. [%p]\r\nData: %s",this,data);
|
||||
XDebug(m_engine,DebugAll,"Stream::writeSocket [%p] Data:\r\n%s",this,data);
|
||||
int c = m_socket->send(data,len);
|
||||
if (c == Socket::socketError()) {
|
||||
c = 0;
|
||||
|
|
|
@ -381,7 +381,7 @@ JGEvent* JGSession::processEvent(JBEvent* jbev, u_int64_t time)
|
|||
if (isResponse(jbev) || time > m_timeout) {
|
||||
DDebug(m_engine,DebugAll,
|
||||
"Session. Terminated in state Ending. Reason: '%s'. [%p]",
|
||||
this,time > m_timeout ? "timeout" : "hangup");
|
||||
time > m_timeout ? "timeout" : "hangup",this);
|
||||
event = new JGEvent(JGEvent::Destroy,this);
|
||||
}
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ bool JGSession::initiate(XMLElement* media, XMLElement* transport)
|
|||
if (incoming() || state() != Idle)
|
||||
return false;
|
||||
DDebug(m_engine,DebugAll,"Session. Initiate from '%s' to '%s'. [%p]",
|
||||
this,m_localJID.c_str(),m_remoteJID.c_str());
|
||||
m_localJID.c_str(),m_remoteJID.c_str(),this);
|
||||
XMLElement* xml = createJingleSet(ActInitiate,media,transport);
|
||||
if (sendXML(xml))
|
||||
m_state = Pending;
|
||||
|
|
|
@ -742,8 +742,13 @@ bool YJBPresence::get(const JabberID& local, JabberID& remote, bool& newPresence
|
|||
yup->remote().match(remote)) {
|
||||
// We found a remote user for the local one. Set the resource
|
||||
remote.resource(yup->remote().resource());
|
||||
if (iplugin.m_jg->requestSubscribe())
|
||||
if (iplugin.m_jg->requestSubscribe()) {
|
||||
bool avail = yup->available();
|
||||
yup->send(JBPresence::Subscribe);
|
||||
// simulate a new presence while we get an answer
|
||||
newPresence = !avail;
|
||||
return avail;
|
||||
}
|
||||
break;
|
||||
}
|
||||
yup = 0;
|
||||
|
@ -1597,7 +1602,7 @@ void YJGConnection::handleEvent(JGEvent* event)
|
|||
break;
|
||||
default:
|
||||
DDebug(this,DebugCall,"handleEvent((%p): %u). [%p]",
|
||||
this,event,event->type());
|
||||
event,event->type(),event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1731,6 +1736,7 @@ void YJGLibThread::run()
|
|||
iplugin.m_presence->runProcess();
|
||||
break;
|
||||
}
|
||||
DDebug(iplugin.m_jb,DebugAll,"%s end of run.",name());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue