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>
This commit is contained in:
parent
618c5f854f
commit
49a9c50ea8
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user