From 4d0c4b9f09b35d707d437611519d0024f6f87a8c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 17 Jun 2010 13:38:27 +0200 Subject: QLocalSocket/Win: handle ERROR_MORE_DATA after read operation If we're connected to a name pipe which is in message mode, we have to handle the following case: ReadFile() or GetOverlappedResult() return FALSE and GetLastError() returns ERROR_MORE_DATA. This just means, that the message didn't fit into the pipe's internal buffer. We must not handle this as error. Task-number: QTBUG-11490 Reviewed-by: ossi --- src/network/socket/qlocalsocket_win.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 5486f47..4907f2c 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -280,6 +280,12 @@ void QLocalSocketPrivate::startAsyncRead() case ERROR_IO_PENDING: // This is not an error. We're getting notified, when data arrives. return; + case ERROR_MORE_DATA: + // This is not an error. The synchronous read succeeded. + // We're connected to a message mode pipe and the message + // didn't fit into the pipe's system buffer. + completeAsyncRead(); + break; case ERROR_PIPE_NOT_CONNECTED: { // It may happen, that the other side closes the connection directly @@ -309,9 +315,18 @@ bool QLocalSocketPrivate::completeAsyncRead() DWORD bytesRead; if (!GetOverlappedResult(handle, &overlapped, &bytesRead, TRUE)) { - if (GetLastError() != ERROR_PIPE_NOT_CONNECTED) + switch (GetLastError()) { + case ERROR_MORE_DATA: + // This is not an error. We're connected to a message mode + // pipe and the message didn't fit into the pipe's system + // buffer. We will read the remaining data in the next call. + break; + case ERROR_PIPE_NOT_CONNECTED: setErrorString(QLatin1String("QLocalSocketPrivate::completeAsyncRead")); - return false; + // fall through + default: + return false; + } } actualReadBufferSize += bytesRead; -- cgit v0.12