summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-12-07 18:23:22 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-12-07 18:23:22 (GMT)
commite32059da8bffc67806862bf78f762d67fb3e4848 (patch)
tree529f5481dc8b832090c778874a0255cbc1c73524
parent2e1bed9790ce11d856006aaa8692fed225cc10d3 (diff)
downloadswift-e32059da8bffc67806862bf78f762d67fb3e4848.zip
swift-e32059da8bffc67806862bf78f762d67fb3e4848.tar.bz2
Fixed segfault on disconnect.
-rw-r--r--Swiften/Client/Client.cpp7
-rw-r--r--Swiften/Client/ClientSession.cpp3
-rw-r--r--Swiften/Client/ClientSession.h1
3 files changed, 8 insertions, 3 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index e9de19a..27f3d9c 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -69,15 +69,16 @@ void Client::handleConnectorFinished(boost::shared_ptr<Connection> connection) {
}
}
void Client::disconnect() {
if (session_) {
session_->finish();
- session_.reset();
}
- closeConnection();
+ else {
+ closeConnection();
+ }
}
void Client::closeConnection() {
if (sessionStream_) {
sessionStream_.reset();
}
@@ -133,12 +134,13 @@ void Client::handleElement(boost::shared_ptr<Element> element) {
void Client::setCertificate(const String& certificate) {
certificate_ = certificate;
}
void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
+ session_.reset();
closeConnection();
if (error) {
ClientError clientError;
if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) {
switch(actualError->type) {
case ClientSession::Error::AuthenticationFailedError:
@@ -188,13 +190,12 @@ void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
clientError = ClientError(ClientError::ConnectionWriteError);
break;
}
}
onError(clientError);
}
- session_.reset();
}
void Client::handleNeedCredentials() {
assert(session_);
session_->sendCredentials(password_);
}
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 8427d27..16bda40 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -31,12 +31,15 @@ ClientSession::ClientSession(
state(Initial),
stream(stream),
needSessionStart(false),
authenticator(NULL) {
}
+ClientSession::~ClientSession() {
+}
+
void ClientSession::start() {
stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1));
stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1));
stream->onError.connect(boost::bind(&ClientSession::handleStreamError, shared_from_this(), _1));
stream->onTLSEncrypted.connect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this()));
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index ef4d747..685672e 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -43,12 +43,13 @@ namespace Swift {
TLSClientCertificateError,
TLSError,
} type;
Error(Type type) : type(type) {}
};
+ ~ClientSession();
static boost::shared_ptr<ClientSession> create(const JID& jid, boost::shared_ptr<SessionStream> stream) {
return boost::shared_ptr<ClientSession>(new ClientSession(jid, stream));
}
State getState() const {
return state;