From bea648fcd6bce4f0d7f19725f60e5b2b3ef0a340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Thu, 29 Sep 2011 21:44:43 +0200 Subject: Temporarily reverting the previous patch, because of unforeseen problems. Will recommit at a later time. This reverts commit 639c0b7c7fe05bd7a686d16d93f2720bd3bfad99. diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index 534ebdb..043743e 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -51,7 +51,7 @@ class SharedBuffer { // ----------------------------------------------------------------------------- BoostConnection::BoostConnection(boost::shared_ptr ioService, EventLoop* eventLoop) : - eventLoop(eventLoop), ioService(ioService), socket_(*ioService), writing_(false), closeSocketAfterNextWrite_(false) { + eventLoop(eventLoop), ioService(ioService), socket_(*ioService), writing_(false) { } BoostConnection::~BoostConnection() { @@ -75,11 +75,10 @@ void BoostConnection::disconnect() { // 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(). - if (writing_) { - closeSocketAfterNextWrite_ = true; - } else { - socket_.close(); + while (writing_) { + Swift::sleep(10); } + socket_.close(); } void BoostConnection::write(const SafeByteArray& data) { @@ -87,9 +86,6 @@ void BoostConnection::write(const SafeByteArray& data) { if (!writing_) { writing_ = true; doWrite(data); - if (closeSocketAfterNextWrite_) { - socket_.close(); - } } else { append(writeQueue_, data); diff --git a/Swiften/Network/BoostConnection.h b/Swiften/Network/BoostConnection.h index 2f0c7be..7d5ec60 100644 --- a/Swiften/Network/BoostConnection.h +++ b/Swiften/Network/BoostConnection.h @@ -63,6 +63,5 @@ namespace Swift { boost::mutex writeMutex_; bool writing_; SafeByteArray writeQueue_; - bool closeSocketAfterNextWrite_; }; } -- cgit v0.10.2-6-g49f6