summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-03-01 15:47:15 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-14 09:49:28 +0100
commit17869a544e2a3b2cdc61dfe87a96a8c1a3286fff (patch)
tree51e913ad5b3b3cbce651e7d47d629de10edc809e
parentba75f604499d3c4fc15930731814fdb9415fdc83 (diff)
fix spurious QWindowsPipeWriter deadlock
We must check the return value of CancelIo(Ex) and only wait for a notification if it was successful. CancelIoEx can fail, if the handle is closed before the QWindowsPipeWriter destructor is called. Change-Id: I2dcc97052be917c69d18c277856374cbc07e2169 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r--src/corelib/io/qwindowspipereader.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index efadb357a9..2cb5845768 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -64,7 +64,7 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
connect(dataReadNotifier, &QWinOverlappedIoNotifier::notified, this, &QWindowsPipeReader::notified);
}
-static void qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
+static bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
{
typedef BOOL (WINAPI *PtrCancelIoEx)(HANDLE, LPOVERLAPPED);
static PtrCancelIoEx ptrCancelIoEx = 0;
@@ -74,16 +74,18 @@ static void qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
ptrCancelIoEx = PtrCancelIoEx(GetProcAddress(kernel32, "CancelIoEx"));
}
if (ptrCancelIoEx)
- ptrCancelIoEx(handle, overlapped);
+ return ptrCancelIoEx(handle, overlapped);
else
- CancelIo(handle);
+ return CancelIo(handle);
}
QWindowsPipeReader::~QWindowsPipeReader()
{
if (readSequenceStarted) {
- qt_cancelIo(handle, &overlapped);
- dataReadNotifier->waitForNotified(-1, &overlapped);
+ if (qt_cancelIo(handle, &overlapped))
+ dataReadNotifier->waitForNotified(-1, &overlapped);
+ else
+ qErrnoWarning("QWindowsPipeReader: qt_cancelIo on handle %x failed.", handle);
}
}