summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-02-03 19:37:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-02-03 19:37:49 (GMT)
commit42a1bbc568aab7e5b29c7fe16c13659291d01cae (patch)
treee554e83883497d7fdd6861c365204fa02380eedc
parent5b9e776a70fa83aafa83a02ea1dc04c06f02734f (diff)
downloadswift-42a1bbc568aab7e5b29c7fe16c13659291d01cae.zip
swift-42a1bbc568aab7e5b29c7fe16c13659291d01cae.tar.bz2
Correct previous patch.
-rw-r--r--Swiften/Network/BoostConnection.cpp12
-rw-r--r--Swiften/Network/BoostConnection.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index b6b2d9d..1d4bd32 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -79,11 +79,16 @@ void BoostConnection::disconnect() {
if (writing_) {
closeSocketAfterNextWrite_ = true;
} else {
- socket_.shutdown();
- socket_.close();
+ closeSocket();
}
}
+void BoostConnection::closeSocket() {
+ boost::system::error_code errorCode;
+ socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, errorCode);
+ socket_.close();
+}
+
void BoostConnection::write(const SafeByteArray& data) {
boost::lock_guard<boost::mutex> lock(writeMutex_);
if (!writing_) {
@@ -149,8 +154,7 @@ void BoostConnection::handleDataWritten(const boost::system::error_code& error)
if (writeQueue_.empty()) {
writing_ = false;
if (closeSocketAfterNextWrite_) {
- socket_.shutdown();
- socket_.close();
+ closeSocket();
}
}
else {
diff --git a/Swiften/Network/BoostConnection.h b/Swiften/Network/BoostConnection.h
index 2f0c7be..0e29c54 100644
--- a/Swiften/Network/BoostConnection.h
+++ b/Swiften/Network/BoostConnection.h
@@ -54,6 +54,7 @@ namespace Swift {
void handleDataWritten(const boost::system::error_code& error);
void doRead();
void doWrite(const SafeByteArray& data);
+ void closeSocket();
private:
EventLoop* eventLoop;