Commit bf6025e0 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ntdll: Do not queue a completion status if pipe ops fail synchronously.

This fixes random crashes when exiting Chromium or shutting down CEF. It is similar to 7a114203, just for pipes. Signed-off-by: 's avatarStefan Dösinger <stefan@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6eec34a9
......@@ -1076,6 +1076,45 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
}
trace("Server done writing.\n");
/* Client will finish this connection, the following ops will trigger broken pipe errors. */
/* Wait for the pipe to break. */
while (PeekNamedPipe(hnp, NULL, 0, NULL, &written, &written));
trace("Server writing on disconnected pipe...\n");
SetLastError(ERROR_SUCCESS);
success = WriteFile(hnp, buf, readden, &written, &oWrite);
err = GetLastError();
todo_wine_if (!success && err == ERROR_PIPE_NOT_CONNECTED) ok(!success && err == ERROR_NO_DATA,
"overlapped WriteFile on disconnected pipe returned %u, err=%i\n", success, err);
/* No completion status is queued on immediate error. */
SetLastError(ERROR_SUCCESS);
oResult = (OVERLAPPED *)0xdeadbeef;
success = GetQueuedCompletionStatus(hcompletion, &written, &compkey,
&oResult, 0);
err = GetLastError();
ok(!success && err == WAIT_TIMEOUT && !oResult,
"WriteFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
success, err, oResult);
trace("Server reading from disconnected pipe...\n");
SetLastError(ERROR_SUCCESS);
success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead);
trace("Server ReadFile from disconnected pipe returned...\n");
err = GetLastError();
ok(!success && err == ERROR_BROKEN_PIPE,
"overlapped ReadFile on disconnected pipe returned %u, err=%i\n", success, err);
SetLastError(ERROR_SUCCESS);
oResult = (OVERLAPPED *)0xdeadbeef;
success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey,
&oResult, 0);
err = GetLastError();
ok(!success && err == WAIT_TIMEOUT && !oResult,
"ReadFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
success, err, oResult);
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
success = DisconnectNamedPipe(hnp);
......
......@@ -937,7 +937,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
break;
default:
status = STATUS_PIPE_BROKEN;
goto done;
goto err;
}
}
else if (type == FD_TYPE_FILE) continue; /* no async I/O on regular files */
......@@ -946,7 +946,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
{
if (errno == EINTR) continue;
if (!total) status = FILE_GetNtStatus();
goto done;
goto err;
}
if (async_read)
......@@ -1331,7 +1331,7 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
if (errno == EFAULT) status = STATUS_INVALID_USER_BUFFER;
else status = FILE_GetNtStatus();
}
goto done;
goto err;
}
if (async_write)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment