summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-12-18 18:50:50 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-12-18 18:50:50 (GMT)
commit312a114c7e204cfe4cfe961509ab9b24ccde7860 (patch)
tree7649aba8b50de49f5259709ee3d34b035d83b33b /Swiften/Network/PlatformDomainNameResolver.h
parent790dd3e97c6634f6a256f2e072507b9d5f29348b (diff)
downloadswift-312a114c7e204cfe4cfe961509ab9b24ccde7860.zip
swift-312a114c7e204cfe4cfe961509ab9b24ccde7860.tar.bz2
Move all domain name resolve queries into one thread.
This avoids reentrancy problems on some platform DNS calls. Resolves: #443
Diffstat (limited to 'Swiften/Network/PlatformDomainNameResolver.h')
-rw-r--r--Swiften/Network/PlatformDomainNameResolver.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/Swiften/Network/PlatformDomainNameResolver.h b/Swiften/Network/PlatformDomainNameResolver.h
index 46c209b..249f2e3 100644
--- a/Swiften/Network/PlatformDomainNameResolver.h
+++ b/Swiften/Network/PlatformDomainNameResolver.h
@@ -6,7 +6,15 @@
#pragma once
-#include "Swiften/Network/DomainNameResolver.h"
+#include <deque>
+#include <boost/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
+
+#include <Swiften/Network/DomainNameResolver.h>
+#include <Swiften/Network/PlatformDomainNameQuery.h>
+#include <Swiften/Network/DomainNameServiceQuery.h>
+#include <Swiften/Network/DomainNameAddressQuery.h>
namespace Swift {
class String;
@@ -15,11 +23,23 @@ namespace Swift {
class PlatformDomainNameResolver : public DomainNameResolver {
public:
PlatformDomainNameResolver(EventLoop* eventLoop);
+ ~PlatformDomainNameResolver();
+
+ virtual DomainNameServiceQuery::ref createServiceQuery(const String& name);
+ virtual DomainNameAddressQuery::ref createAddressQuery(const String& name);
- virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& name);
- virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& name);
+ private:
+ void run();
+ void addQueryToQueue(PlatformDomainNameQuery::ref);
private:
+ friend class PlatformDomainNameServiceQuery;
+ friend class PlatformDomainNameAddressQuery;
EventLoop* eventLoop;
+ bool stopRequested;
+ boost::thread* thread;
+ std::deque<PlatformDomainNameQuery::ref> queue;
+ boost::mutex queueMutex;
+ boost::condition_variable queueNonEmpty;
};
}