summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;