summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/BOSHConnectionPool.cpp')
-rw-r--r--Swiften/Network/BOSHConnectionPool.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp
index e4ca471..8a75e81 100644
--- a/Swiften/Network/BOSHConnectionPool.cpp
+++ b/Swiften/Network/BOSHConnectionPool.cpp
@@ -115,60 +115,61 @@ void BOSHConnectionPool::close() {
else {
pendingTerminate = true;
std::vector<BOSHConnection::ref> connectionCopies = connections;
for (auto&& connection : connectionCopies) {
if (connection) {
connection->disconnect();
}
}
}
}
void BOSHConnectionPool::handleSessionStarted(const std::string& sessionID, size_t requests) {
sid = sessionID;
requestLimit = requests;
onSessionStarted();
}
void BOSHConnectionPool::handleConnectFinished(bool error, BOSHConnection::ref connection) {
if (error) {
onSessionTerminated(std::make_shared<BOSHError>(BOSHError::UndefinedCondition));
/*TODO: We can probably manage to not terminate the stream here and use the rid/ack retry
* logic to just swallow the error and try again (some number of tries).
*/
}
else {
if (connection->getPeerCertificate() && pinnedCertificateChain_.empty()) {
pinnedCertificateChain_ = connection->getPeerCertificateChain();
}
if (!pinnedCertificateChain_.empty()) {
lastVerificationError_ = connection->getPeerCertificateVerificationError();
+ onTLSConnectionEstablished();
}
if (sid.empty()) {
connection->startStream(to, rid);
}
if (pendingRestart) {
restartStream();
}
tryToSendQueuedData();
}
}
BOSHConnection::ref BOSHConnectionPool::getSuitableConnection() {
BOSHConnection::ref suitableConnection;
for (auto&& connection : connections) {
if (connection->isReadyToSend()) {
suitableConnection = connection;
break;
}
}
if (!suitableConnection && connections.size() < requestLimit) {
/* This is not a suitable connection because it won't have yet connected and added TLS if needed. */
BOSHConnection::ref newConnection = createConnection();
newConnection->setSID(sid);
}
assert(connections.size() <= requestLimit);
assert((!suitableConnection) || suitableConnection->isReadyToSend());
return suitableConnection;
}