Skip to content

Commit 4d0c4b9

Browse files
author
Joerg Bornemann
committed
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
1 parent 600a19a commit 4d0c4b9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/network/socket/qlocalsocket_win.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ void QLocalSocketPrivate::startAsyncRead()
280280
case ERROR_IO_PENDING:
281281
// This is not an error. We're getting notified, when data arrives.
282282
return;
283+
case ERROR_MORE_DATA:
284+
// This is not an error. The synchronous read succeeded.
285+
// We're connected to a message mode pipe and the message
286+
// didn't fit into the pipe's system buffer.
287+
completeAsyncRead();
288+
break;
283289
case ERROR_PIPE_NOT_CONNECTED:
284290
{
285291
// It may happen, that the other side closes the connection directly
@@ -309,9 +315,18 @@ bool QLocalSocketPrivate::completeAsyncRead()
309315

310316
DWORD bytesRead;
311317
if (!GetOverlappedResult(handle, &overlapped, &bytesRead, TRUE)) {
312-
if (GetLastError() != ERROR_PIPE_NOT_CONNECTED)
318+
switch (GetLastError()) {
319+
case ERROR_MORE_DATA:
320+
// This is not an error. We're connected to a message mode
321+
// pipe and the message didn't fit into the pipe's system
322+
// buffer. We will read the remaining data in the next call.
323+
break;
324+
case ERROR_PIPE_NOT_CONNECTED:
313325
setErrorString(QLatin1String("QLocalSocketPrivate::completeAsyncRead"));
314-
return false;
326+
// fall through
327+
default:
328+
return false;
329+
}
315330
}
316331

317332
actualReadBufferSize += bytesRead;

0 commit comments

Comments
 (0)