Network::clearCaps only sync when caps removed
authorShane Synan <digitalcircuit36939@gmail.com>
Sun, 28 Aug 2016 21:49:07 +0000 (16:49 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 7 Sep 2016 19:29:32 +0000 (21:29 +0200)
Add check for if _caps and _capsEnabled contain any capabilities.  If
not, return from the clearCaps call without issuing a network SYNC.

Fixes needless clearCaps calls when reconnecting to a network that's
failing to connect.

This may cause inconsistency if clients miss some sync calls.. but
Quassel protocol currently depends on all sync calls being propogated
anyways.

src/common/network.cpp

index cde2af7..b1e4519 100644 (file)
@@ -746,6 +746,10 @@ void Network::removeCap(const QString &capability)
 void Network::clearCaps()
 {
     // IRCv3 specs all use lowercase capability names
+    if (_caps.empty() && _capsEnabled.empty()) {
+        // Avoid the sync call if there's nothing to clear (e.g. failed reconnects)
+        return;
+    }
     // To ease core-side configuration, loop through the list and emit capRemoved for each entry.
     // If performance issues arise, this can be converted to a more-efficient setup without breaking
     // protocol (in theory).