diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2012-09-29 18:37:56 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 08:06:06 +0200 |
commit | 49a9c50ea8b7cbe92684a707f985792b06d17f1e (patch) | |
tree | 762a395c233f13f73c85fad4ea5ad427ef8be1de /src/corelib/io/qwindowspipereader.cpp | |
parent | 618c5f854faddbc5b614ae5a399ca2af4848a1ab (diff) |
QWindowsPipeReader: use CancelIoEx on Windows >= Vista
This cancels only the I/O operation of the reader and not all
operations on the handle.
Change-Id: Ie442199534cf45e58bb2e053da9fecee961a460e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib/io/qwindowspipereader.cpp')
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 8a06a7ba21..cca6e80810 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -64,10 +64,25 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent) connect(dataReadNotifier, &QWinOverlappedIoNotifier::notified, this, &QWindowsPipeReader::notified); } +static void qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped) +{ + typedef BOOL (WINAPI *PtrCancelIoEx)(HANDLE, LPOVERLAPPED); + static PtrCancelIoEx ptrCancelIoEx = 0; + if (!ptrCancelIoEx) { + HMODULE kernel32 = GetModuleHandleA("kernel32"); + if (kernel32) + ptrCancelIoEx = PtrCancelIoEx(GetProcAddress(kernel32, "CancelIoEx")); + } + if (ptrCancelIoEx) + ptrCancelIoEx(handle, overlapped); + else + CancelIo(handle); +} + QWindowsPipeReader::~QWindowsPipeReader() { if (readSequenceStarted) { - CancelIo(handle); + qt_cancelIo(handle, &overlapped); dataReadNotifier->waitForNotified(-1, &overlapped); } } |