summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-06-23 20:50:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-06-23 20:50:50 +0300
commit663a045a164f8973d4f66e2d8e45b495eb0519e6 (patch)
tree77cb24348e730dc0debda8e2e1f3207d26fa6f96 /protocols
parenta53e822aec3f226b73989044ddb7a35daa212b4a (diff)
Jabber: more effective stream management processing
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_strm_mgmt.cpp17
-rw-r--r--protocols/JabberG/src/jabber_strm_mgmt.h2
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp7
3 files changed, 16 insertions, 10 deletions
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp
index cc6d35f60d..93bacf04de 100644
--- a/protocols/JabberG/src/jabber_strm_mgmt.cpp
+++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp
@@ -198,7 +198,8 @@ void strm_mgmt::HandleOutgoingNode(TiXmlElement *node)
m_nStrmMgmtLocalSCount++;
NodeCache.push_back(pNodeCopy);
- if ((m_nStrmMgmtLocalSCount - m_nStrmMgmtSrvHCount) >= m_nStrmMgmtCacheSize)
+ if ((m_nStrmMgmtLocalSCount - m_nStrmMgmtSrvHCount) >= m_nStrmMgmtCacheSize
+ || m_nStrmMgmtLocalSCount % 3 == 0)
RequestAck();
}
@@ -213,14 +214,20 @@ void strm_mgmt::ResetState()
m_sStrmMgmtResumeId.clear();
}
-void strm_mgmt::HandleIncommingNode(const TiXmlElement *node)
+bool strm_mgmt::HandleIncommingNode(const TiXmlElement *node)
{
- if (m_bStrmMgmtEnabled && mir_strcmp(node->Name(), "r") && mir_strcmp(node->Name(), "a")) //TODO: something better
- m_nStrmMgmtLocalHCount++;
- else if (!mir_strcmp(node->Name(), "r"))
+ if (!m_bStrmMgmtEnabled)
+ return false;
+
+ if (!mir_strcmp(node->Name(), "r"))
OnProcessSMr(node);
else if (!mir_strcmp(node->Name(), "a"))
OnProcessSMa(node);
+ else {
+ m_nStrmMgmtLocalHCount++;
+ return false;
+ }
+ return true;
}
void strm_mgmt::EnableStrmMgmt()
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.h b/protocols/JabberG/src/jabber_strm_mgmt.h
index 82ea789f75..0cfa01f1df 100644
--- a/protocols/JabberG/src/jabber_strm_mgmt.h
+++ b/protocols/JabberG/src/jabber_strm_mgmt.h
@@ -48,7 +48,7 @@ public:
strm_mgmt(CJabberProto *proto);
void EnableStrmMgmt();
void HandleOutgoingNode(TiXmlElement *node);
- void HandleIncommingNode(const TiXmlElement *node);
+ bool HandleIncommingNode(const TiXmlElement *node);
void OnProcessEnabled(const TiXmlElement *node, ThreadData *info);
void OnProcessResumed(const TiXmlElement *node, ThreadData *info);
void OnProcessFailed(const TiXmlElement *node, ThreadData * info);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index c39179463a..f3e1439c89 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -152,9 +152,6 @@ void CJabberProto::CheckKeepAlive()
}
}
- if (m_bEnableStreamMgmt)
- m_StrmMgmt.RequestAck();
-
// check expired iq requests
m_iqManager.CheckExpired();
@@ -836,7 +833,9 @@ void CJabberProto::OnProcessProtocol(const TiXmlElement *node, ThreadData *info)
OnConsoleProcessXml(node, JCPF_IN);
if (m_bEnableStreamMgmt)
- m_StrmMgmt.HandleIncommingNode(node);
+ if(m_StrmMgmt.HandleIncommingNode(node))
+ return;
+
if (!mir_strcmp(node->Name(), "proceed"))
OnProcessProceed(node, info);
else if (!mir_strcmp(node->Name(), "compressed"))