diff options
-rw-r--r-- | Swiften/Network/BoostConnection.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index 7b997b4..b6b2d9d 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -73,18 +73,19 @@ void BoostConnection::disconnect() { //MainEventLoop::removeEventsFromOwner(shared_from_this()); // Mac OS X apparently exhibits a problem where closing a socket during a write could potentially go into uninterruptable sleep. // See e.g. http://bugs.python.org/issue7401 // We therefore wait until any pending write finishes, which hopefully should fix our hang on exit during close(). boost::lock_guard<boost::mutex> lock(writeMutex_); if (writing_) { closeSocketAfterNextWrite_ = true; } else { + socket_.shutdown(); socket_.close(); } } void BoostConnection::write(const SafeByteArray& data) { boost::lock_guard<boost::mutex> lock(writeMutex_); if (!writing_) { writing_ = true; doWrite(data); @@ -142,18 +143,19 @@ void BoostConnection::handleDataWritten(const boost::system::error_code& error) } else { eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), WriteError), shared_from_this()); } { boost::lock_guard<boost::mutex> lock(writeMutex_); if (writeQueue_.empty()) { writing_ = false; if (closeSocketAfterNextWrite_) { + socket_.shutdown(); socket_.close(); } } else { doWrite(writeQueue_); writeQueue_.clear(); } } } |