summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
index 82fd17e..812adbe 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
@@ -2,13 +2,13 @@
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include "SOCKS5BytestreamClientSession.h"
@@ -33,13 +33,13 @@ SOCKS5BytestreamClientSession::SOCKS5BytestreamClientSession(
TimerFactory* timerFactory) :
connection(connection),
addressPort(addressPort),
destination(destination),
state(Initial),
chunkSize(131072) {
- weFailedTimeout = timerFactory->createTimer(2000);
+ weFailedTimeout = timerFactory->createTimer(3000);
weFailedTimeout->onTick.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleWeFailedTimeout, this));
}
SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() {
}
@@ -52,12 +52,15 @@ void SOCKS5BytestreamClientSession::start() {
boost::bind(&SOCKS5BytestreamClientSession::handleConnectFinished, this, _1));
connection->connect(addressPort);
}
void SOCKS5BytestreamClientSession::stop() {
SWIFT_LOG(debug) << std::endl;
+ if (state < Ready) {
+ weFailedTimeout->stop();
+ }
if (state == Finished) {
return;
}
closeConnection();
readBytestream.reset();
state = Finished;
@@ -198,13 +201,15 @@ void SOCKS5BytestreamClientSession::sendData() {
finish(false);
}
}
void SOCKS5BytestreamClientSession::finish(bool error) {
SWIFT_LOG(debug) << std::endl;
- weFailedTimeout->stop();
+ if (state < Ready) {
+ weFailedTimeout->stop();
+ }
closeConnection();
readBytestream.reset();
if (state == Initial || state == Hello || state == Authenticating) {
onSessionReady(true);
}
else {
@@ -225,12 +230,13 @@ void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) {
} else {
SWIFT_LOG(debug) << "Successfully connected via TCP" << addressPort.toString() << "." << std::endl;
disconnectedConnection = connection->onDisconnected.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleDisconnected, this, _1));
dataReadConnection = connection->onDataRead.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleDataRead, this, _1));
+ weFailedTimeout->stop();
weFailedTimeout->start();
process();
}
}
void SOCKS5BytestreamClientSession::handleDataRead(boost::shared_ptr<SafeByteArray> data) {