summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/Client/CoreClient.cpp3
-rw-r--r--Swiften/Network/Connector.cpp21
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.cpp5
3 files changed, 19 insertions, 10 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 8658168..e61f9f9 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -18,6 +18,7 @@
#include "Swiften/Queries/IQRouter.h"
#include "Swiften/Base/IDGenerator.h"
#include "Swiften/Client/ClientSessionStanzaChannel.h"
+#include <Swiften/Base/Log.h>
namespace Swift {
@@ -47,10 +48,12 @@ CoreClient::~CoreClient() {
}
void CoreClient::connect() {
+ SWIFT_LOG(debug) << "Connecting" << std::endl;
connect(jid_.getDomain());
}
void CoreClient::connect(const String& host) {
+ SWIFT_LOG(debug) << "Connecting to host " << host << std::endl;
disconnectRequested_ = false;
assert(!connector_);
connector_ = Connector::create(host, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory());
diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp
index 63fc2f9..28088c5 100644
--- a/Swiften/Network/Connector.cpp
+++ b/Swiften/Network/Connector.cpp
@@ -13,6 +13,7 @@
#include "Swiften/Network/DomainNameResolver.h"
#include "Swiften/Network/DomainNameAddressQuery.h"
#include "Swiften/Network/TimerFactory.h"
+#include <Swiften/Base/Log.h>
namespace Swift {
@@ -24,6 +25,7 @@ void Connector::setTimeoutMilliseconds(int milliseconds) {
}
void Connector::start() {
+ SWIFT_LOG(debug) << "Starting connector for " << hostname << std::endl;
//std::cout << "Connector::start()" << std::endl;
assert(!currentConnection);
assert(!serviceQuery);
@@ -51,7 +53,7 @@ void Connector::queryAddress(const String& hostname) {
}
void Connector::handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result) {
- //std::cout << "Received SRV results" << std::endl;
+ SWIFT_LOG(debug) << result.size() << " SRV result(s)" << std::endl;
serviceQueryResults = std::deque<DomainNameServiceQuery::Result>(result.begin(), result.end());
serviceQuery.reset();
tryNextServiceOrFallback();
@@ -59,23 +61,23 @@ void Connector::handleServiceQueryResult(const std::vector<DomainNameServiceQuer
void Connector::tryNextServiceOrFallback() {
if (queriedAllServices) {
- //std::cout << "Connector::tryNextServiceOrCallback(): Queried all hosts. Error." << std::endl;
+ SWIFT_LOG(debug) << "Queried all services" << std::endl;
finish(boost::shared_ptr<Connection>());
}
else if (serviceQueryResults.empty()) {
- //std::cout << "Connector::tryNextHostName(): Falling back on A resolution" << std::endl;
+ SWIFT_LOG(debug) << "Falling back on A resolution" << std::endl;
// Fall back on simple address resolving
queriedAllServices = true;
queryAddress(hostname);
}
else {
- //std::cout << "Connector::tryNextHostName(): Querying next address" << std::endl;
+ SWIFT_LOG(debug) << "Querying next address" << std::endl;
queryAddress(serviceQueryResults.front().hostname);
}
}
void Connector::handleAddressQueryResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error) {
- //std::cout << "Connector::handleAddressQueryResult(): Start" << std::endl;
+ SWIFT_LOG(debug) << addresses.size() << " addresses" << std::endl;
addressQuery.reset();
if (error || addresses.empty()) {
if (!serviceQueryResults.empty()) {
@@ -91,7 +93,7 @@ void Connector::handleAddressQueryResult(const std::vector<HostAddress>& address
void Connector::tryNextAddress() {
if (addressQueryResults.empty()) {
- //std::cout << "Connector::tryNextAddress(): Done trying addresses. Moving on" << std::endl;
+ SWIFT_LOG(debug) << "Done trying addresses. Moving on." << std::endl;
// Done trying all addresses. Move on to the next host.
if (!serviceQueryResults.empty()) {
serviceQueryResults.pop_front();
@@ -99,7 +101,7 @@ void Connector::tryNextAddress() {
tryNextServiceOrFallback();
}
else {
- //std::cout << "Connector::tryNextAddress(): trying next address." << std::endl;
+ SWIFT_LOG(debug) << "Trying next address" << std::endl;
HostAddress address = addressQueryResults.front();
addressQueryResults.pop_front();
@@ -114,14 +116,14 @@ void Connector::tryNextAddress() {
void Connector::tryConnect(const HostAddressPort& target) {
assert(!currentConnection);
- //std::cout << "Connector::tryConnect() " << target.getAddress().toString() << " " << target.getPort() << std::endl;
+ SWIFT_LOG(debug) << "Trying to connect to " << target.getAddress().toString() << ":" << target.getPort() << std::endl;
currentConnection = connectionFactory->createConnection();
currentConnection->onConnectFinished.connect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1));
currentConnection->connect(target);
}
void Connector::handleConnectionConnectFinished(bool error) {
- //std::cout << "Connector::handleConnectionConnectFinished() " << error << std::endl;
+ SWIFT_LOG(debug) << "ConnectFinished: " << (error ? "error" : "success") << std::endl;
currentConnection->onConnectFinished.disconnect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1));
if (error) {
currentConnection.reset();
@@ -162,6 +164,7 @@ void Connector::finish(boost::shared_ptr<Connection> connection) {
}
void Connector::handleTimeout() {
+ SWIFT_LOG(debug) << "Timeout" << std::endl;
finish(boost::shared_ptr<Connection>());
}
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
index ed73b64..7ab6e7a 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
@@ -27,6 +27,7 @@
#include "Swiften/Base/ByteArray.h"
#include "Swiften/EventLoop/EventLoop.h"
#include "Swiften/Base/foreach.h"
+#include <Swiften/Base/Log.h>
using namespace Swift;
@@ -51,6 +52,8 @@ void PlatformDomainNameServiceQuery::run() {
}
void PlatformDomainNameServiceQuery::doRun() {
+ SWIFT_LOG(debug) << "Querying " << service << std::endl;
+
std::vector<DomainNameServiceQuery::Result> records;
#if defined(SWIFTEN_PLATFORM_WINDOWS)
@@ -84,11 +87,11 @@ void PlatformDomainNameServiceQuery::doRun() {
// Make sure we reinitialize the domain list every time
res_init();
- //std::cout << "SRV: Querying " << service << std::endl;
ByteArray response;
response.resize(NS_PACKETSZ);
int responseLength = res_query(const_cast<char*>(service.getUTF8Data()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize());
if (responseLength == -1) {
+ SWIFT_LOG(debug) << "Error" << std::endl;
emitError();
return;
}