summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-03-08 16:27:27 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-05-01 17:37:22 (GMT)
commit1bdcf392e7965e5f789b3b3fd026931c61a1cc59 (patch)
tree718293e82bad289c11398f01f3233e5b92775354
parent08f08513e636a8eb36645fdd712105156a754ae2 (diff)
downloadswift-1bdcf392e7965e5f789b3b3fd026931c61a1cc59.zip
swift-1bdcf392e7965e5f789b3b3fd026931c61a1cc59.tar.bz2
Add an EventOwner to NATTraversalRequests so that accociated objects are not released early
This patch also disconnects possible slots on stop() from the signals. Test-Infromation: This fixes a crash that occured during testing with ConcurrentFileTransferTest. Change-Id: I2b443f40ac3359c8142fcffc084647312b9a1e76
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp
index 5e2bc0c..ef1876c 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.cpp
+++ b/Swiften/Network/PlatformNATTraversalWorker.cpp
@@ -12,6 +12,7 @@
#include <Swiften/Base/Log.h>
#include <Swiften/EventLoop/EventLoop.h>
+#include <Swiften/EventLoop/EventOwner.h>
#include <Swiften/Network/NATTraversalGetPublicIPRequest.h>
#include <Swiften/Network/NATTraversalForwardPortRequest.h>
#include <Swiften/Network/NATTraversalRemovePortForwardingRequest.h>
@@ -24,7 +25,7 @@
namespace Swift {
-class PlatformNATTraversalRequest : public boost::enable_shared_from_this<PlatformNATTraversalRequest> {
+class PlatformNATTraversalRequest : public boost::enable_shared_from_this<PlatformNATTraversalRequest>, public EventOwner {
public:
typedef boost::shared_ptr<PlatformNATTraversalRequest> ref;
@@ -59,16 +60,19 @@ class PlatformNATTraversalGetPublicIPRequest : public NATTraversalGetPublicIPReq
PlatformNATTraversalGetPublicIPRequest(PlatformNATTraversalWorker* worker) : PlatformNATTraversalRequest(worker) {
}
+ virtual ~PlatformNATTraversalGetPublicIPRequest() {
+ }
+
virtual void start() {
doRun();
}
virtual void stop() {
- // TODO
+ onResult.disconnect_all_slots();
}
virtual void runBlocking() {
- getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->getPublicIP()));
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->getPublicIP()), shared_from_this());
}
};
@@ -77,16 +81,19 @@ class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortReq
PlatformNATTraversalForwardPortRequest(PlatformNATTraversalWorker* worker, unsigned int localIP, unsigned int publicIP) : PlatformNATTraversalRequest(worker), localIP(localIP), publicIP(publicIP) {
}
+ virtual ~PlatformNATTraversalForwardPortRequest() {
+ }
+
virtual void start() {
doRun();
}
virtual void stop() {
- // TODO
+ onResult.disconnect_all_slots();
}
virtual void runBlocking() {
- getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP))));
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP))), shared_from_this());
}
private:
@@ -99,16 +106,19 @@ class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemov
PlatformNATTraversalRemovePortForwardingRequest(PlatformNATTraversalWorker* worker, const NATPortMapping& mapping) : PlatformNATTraversalRequest(worker), mapping(mapping) {
}
+ virtual ~PlatformNATTraversalRemovePortForwardingRequest() {
+ }
+
virtual void start() {
doRun();
}
virtual void stop() {
- // TODO
+ onResult.disconnect_all_slots();
}
virtual void runBlocking() {
- getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->removePortForward(mapping)));
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->removePortForward(mapping)), shared_from_this());
}
private: