summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-15 16:05:42 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-15 16:05:42 (GMT)
commitc2580661a20e30abaa23c61808d6370a575665c1 (patch)
treee9c436f6830e66ac1f39027233831dc783b9818a /Swiften/Network/BoostConnection.cpp
parentabf3fbe3dc2b56e1f148b999a3003a0ec7e6ef43 (diff)
downloadswift-contrib-c2580661a20e30abaa23c61808d6370a575665c1.zip
swift-contrib-c2580661a20e30abaa23c61808d6370a575665c1.tar.bz2
Wait to close the connection until pending writes are done.
This hopefully fixes the uninterruptable hang on exit.
Diffstat (limited to 'Swiften/Network/BoostConnection.cpp')
-rw-r--r--Swiften/Network/BoostConnection.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index 7751535..2741bc8 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -14,6 +14,7 @@
#include "Swiften/Base/String.h"
#include "Swiften/Base/ByteArray.h"
#include "Swiften/Network/HostAddressPort.h"
+#include "Swiften/Base/sleep.h"
namespace Swift {
@@ -63,6 +64,14 @@ void BoostConnection::connect(const HostAddressPort& addressPort) {
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().
+ while (writing_) {
+ std::cerr << "Write in progress ... waiting to quit" << std::endl;
+ Swift::sleep(10);
+ }
socket_.close();
}