From 42a1bbc568aab7e5b29c7fe16c13659291d01cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Fri, 3 Feb 2012 20:37:49 +0100 Subject: Correct previous patch. 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; -- cgit v0.10.2-6-g49f6