summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-05-20 16:01:06 (GMT)
committerTobias Markmann <tm@ayena.de>2015-05-26 15:43:35 (GMT)
commite544a3ad5a8d3cdf67554384f53895fad34ff9bc (patch)
tree2807a0a190fd9592f9aedb689af3462bc507f156 /Swiften
parent009e94c604e2d892ea8711ed6b3756da3eea9d04 (diff)
downloadswift-e544a3ad5a8d3cdf67554384f53895fad34ff9bc.zip
swift-e544a3ad5a8d3cdf67554384f53895fad34ff9bc.tar.bz2
Fix crash when sending a file to yourself
Use scoped_connection to prevent missing disconnection from signals. Stop and free S5BServer when stopping SOCKS5BytestreamServerManager. Test-Information: Tried sending a file to myself multiple times and it did not crash. Change-Id: If32075d8e9c243cab254776b924248227520e030
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp5
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.cpp12
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h1
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.cpp2
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h1
5 files changed, 15 insertions, 6 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
index 43d3e46..3137163 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
@@ -192,6 +192,10 @@ void SOCKS5BytestreamServerManager::stop() {
forwardPortRequest->stop();
forwardPortRequest.reset();
}
+ if (server) {
+ server->stop();
+ server = NULL;
+ }
if (connectionServer) {
connectionServer->stop();
connectionServer.reset();
@@ -223,6 +227,7 @@ void SOCKS5BytestreamServerManager::handleForwardPortResult(boost::optional<NATP
}
portMapping = mapping;
+ onPortForwardingSetup(mapping.is_initialized());
forwardPortRequest->stop();
forwardPortRequest.reset();
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.cpp
index 9ab097b..e3b6d34 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.cpp
@@ -15,14 +15,16 @@ namespace Swift {
SOCKS5BytestreamServerPortForwardingUser::SOCKS5BytestreamServerPortForwardingUser(SOCKS5BytestreamServerManager* s5bServerManager) : s5bServerManager_(s5bServerManager) {
// the server should be initialized, so we know what port to setup a forward for
assert(s5bServerManager->isInitialized());
- assert(!s5bServerManager_->isPortForwardingReady());
-
- s5bServerManager_->onPortForwardingSetup.connect(boost::bind(&SOCKS5BytestreamServerPortForwardingUser::handleServerManagerPortForwardingSetup, this, _1));
- s5bServerManager_->setupPortForwarding();
+ if (s5bServerManager_->isPortForwardingReady()) {
+ onSetup(!s5bServerManager_->getAssistedHostAddressPorts().empty());
+ }
+ else {
+ onPortForwardingSetupConnection_ = s5bServerManager_->onPortForwardingSetup.connect(boost::bind(&SOCKS5BytestreamServerPortForwardingUser::handleServerManagerPortForwardingSetup, this, _1));
+ s5bServerManager_->setupPortForwarding();
+ }
}
SOCKS5BytestreamServerPortForwardingUser::~SOCKS5BytestreamServerPortForwardingUser() {
- s5bServerManager_->onPortForwardingSetup.disconnect(boost::bind(&SOCKS5BytestreamServerPortForwardingUser::handleServerManagerPortForwardingSetup, this, _1));
if (s5bServerManager_->isPortForwardingReady()) {
s5bServerManager_->removePortForwarding();
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h b/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h
index f486836..c4550d3 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h
@@ -26,6 +26,7 @@ class SOCKS5BytestreamServerPortForwardingUser {
private:
SOCKS5BytestreamServerManager* s5bServerManager_;
+ boost::bsignals::scoped_connection onPortForwardingSetupConnection_;
};
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.cpp
index bf7d4e8..b369347 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.cpp
@@ -14,7 +14,7 @@ namespace Swift {
SOCKS5BytestreamServerResourceUser::SOCKS5BytestreamServerResourceUser(SOCKS5BytestreamServerManager* s5bServerManager) : s5bServerManager_(s5bServerManager) {
assert(!s5bServerManager_->isInitialized());
- s5bServerManager_->onInitialized.connect(boost::bind(&SOCKS5BytestreamServerResourceUser::handleServerManagerInitialized, this, _1));
+ onInitializedConnection_ = s5bServerManager_->onInitialized.connect(boost::bind(&SOCKS5BytestreamServerResourceUser::handleServerManagerInitialized, this, _1));
s5bServerManager_->initialize();
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h b/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h
index 014689b..fa7f42c 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h
@@ -26,6 +26,7 @@ class SOCKS5BytestreamServerResourceUser {
private:
SOCKS5BytestreamServerManager* s5bServerManager_;
+ boost::bsignals::scoped_connection onInitializedConnection_;
};
}