diff --git a/include/Swiften/Elements/SpectrumErrorPayload.h b/include/Swiften/Elements/SpectrumErrorPayload.h index b2b402ff..0fe3cc47 100644 --- a/include/Swiften/Elements/SpectrumErrorPayload.h +++ b/include/Swiften/Elements/SpectrumErrorPayload.h @@ -31,7 +31,7 @@ namespace Swift { CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13, CONNECTION_ERROR_CERT_SELF_SIGNED = 14, CONNECTION_ERROR_CERT_OTHER_ERROR = 15, - CONNECTION_ERROR_OTHER_ERROR = 16, + CONNECTION_ERROR_OTHER_ERROR = 16 }; SpectrumErrorPayload(Error error = CONNECTION_ERROR_OTHER_ERROR); diff --git a/include/transport/networkpluginserver.h b/include/transport/networkpluginserver.h index c04ae834..671c8ba4 100644 --- a/include/transport/networkpluginserver.h +++ b/include/transport/networkpluginserver.h @@ -55,6 +55,7 @@ class NetworkPluginServer { unsigned long shared; bool acceptUsers; bool longRun; + bool willDie; }; NetworkPluginServer(Component *component, Config *config, UserManager *userManager, FileTransferManager *ftManager); diff --git a/src/networkpluginserver.cpp b/src/networkpluginserver.cpp index 64dc9f54..feade943 100644 --- a/src/networkpluginserver.cpp +++ b/src/networkpluginserver.cpp @@ -288,6 +288,7 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptrres = 0; client->init_res = 0; client->shared = 0; + client->willDie = 0; // Backend does not accept new clients automatically if it's long-running client->acceptUsers = !m_isNextLongRun; client->longRun = m_isNextLongRun; @@ -336,6 +337,9 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptrconnection && (*it)->longRun == longRun) { + if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) { c = *it; // if we're not reusing all backends and backend is full, stop accepting new users on this backend if (!CONFIG_BOOL(m_config, "service.reuse_old_backends")) { diff --git a/src/user.cpp b/src/user.cpp index 7d9ec3ab..3f113f8c 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -322,6 +322,15 @@ void User::handleDisconnected(const std::string &error, Swift::SpectrumErrorPayl return; } + if (e == Swift::SpectrumErrorPayload::CONNECTION_ERROR_OTHER_ERROR || e == Swift::SpectrumErrorPayload::CONNECTION_ERROR_NETWORK_ERROR) { + LOG4CXX_INFO(logger, m_jid.toString() << ": Disconnecting from legacy network, trying to reconnect automatically."); + // Simulate destruction/resurrection :) + // TODO: If this stops working, create onReconnect signal + m_userManager->onUserDestroyed(this); + m_userManager->onUserCreated(this); + return; + } + if (error.empty()) { LOG4CXX_INFO(logger, m_jid.toString() << ": Disconnected from legacy network"); }