Commit 56f34c74 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Return STATUS_PENDING from NtWriteFile() for async write with regular file.

This matches Vista+ behaviour. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42982Signed-off-by: 's avatarPaul Gofman <gofmanp@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 53c0eef1
......@@ -1199,7 +1199,7 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
int result, unix_handle, needs_close;
unsigned int options;
struct io_timeouts timeouts;
NTSTATUS status;
NTSTATUS status, ret_status;
ULONG total = 0;
enum server_fd_type type;
ULONG_PTR cvalue = apc ? 0 : (ULONG_PTR)apc_user;
......@@ -1221,6 +1221,8 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
}
if (status && status != STATUS_BAD_DEVICE_TYPE) return status;
async_write = !(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
if (!virtual_check_buffer_for_read( buffer, length ))
{
status = STATUS_INVALID_USER_BUFFER;
......@@ -1230,8 +1232,6 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
if (status == STATUS_BAD_DEVICE_TYPE)
return server_write_file( hFile, hEvent, apc, apc_user, io_status, buffer, length, offset, key );
async_write = !(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
if (type == FD_TYPE_FILE)
{
if (async_write &&
......@@ -1409,9 +1409,10 @@ err:
if (status != STATUS_PENDING && hEvent) NtResetEvent( hEvent, NULL );
}
if (send_completion) NTDLL_AddCompletion( hFile, cvalue, status, total, FALSE );
ret_status = async_write && type == FD_TYPE_FILE && status == STATUS_SUCCESS ? STATUS_PENDING : status;
if (send_completion) NTDLL_AddCompletion( hFile, cvalue, status, total, ret_status == STATUS_PENDING );
return status;
return ret_status;
}
......
......@@ -619,7 +619,7 @@ static void read_file_test(void)
offset.QuadPart = 0;
ResetEvent( event );
status = pNtWriteFile( handle, event, apc, &apc_count, &iosb, text, strlen(text), &offset, NULL );
todo_wine ok( status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
ok( status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
"wrong status %x.\n", status );
if (status == STATUS_PENDING) WaitForSingleObject( event, 1000 );
ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
......@@ -726,7 +726,7 @@ static void read_file_test(void)
ResetEvent(event);
status = pNtWriteFile(handle, event, apc, &apc_count, &iosb,
aligned_buffer, sizeof(aligned_buffer), &offset, NULL);
todo_wine ok(status == STATUS_END_OF_FILE || status == STATUS_PENDING
ok(status == STATUS_END_OF_FILE || status == STATUS_PENDING
|| broken(status == STATUS_SUCCESS) /* before Vista */,
"Wrong status %x.\n", status);
ok(U(iosb).Status == STATUS_SUCCESS, "Wrong status %x.\n", U(iosb).Status);
......@@ -3474,7 +3474,7 @@ static void test_file_completion_information(void)
{
SetLastError(0xdeadbeef);
ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
todo_wine ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
"Unexpected result %#x, GetLastError() %u.\n", ret, GetLastError());
if (ret || GetLastError() != ERROR_IO_PENDING) break;
ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
......@@ -3504,7 +3504,7 @@ static void test_file_completion_information(void)
{
SetLastError(0xdeadbeef);
ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
todo_wine ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
"Unexpected result %#x, GetLastError() %u.\n", ret, GetLastError());
if (ret || GetLastError() != ERROR_IO_PENDING) break;
ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
......@@ -3530,7 +3530,7 @@ static void test_file_completion_information(void)
{
SetLastError(0xdeadbeef);
ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
todo_wine ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* Before Vista */,
"Unexpected result %#x, GetLastError() %u.\n", ret, GetLastError());
if (ret || GetLastError() != ERROR_IO_PENDING) break;
ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
......@@ -4367,7 +4367,7 @@ static void test_read_write(void)
iob.Information = -1;
offset.QuadPart = 0;
status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), &offset, NULL);
todo_wine ok(status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
ok(status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
"expected STATUS_PENDING, got %#x.\n", status);
if (status == STATUS_PENDING)
{
......@@ -4583,7 +4583,7 @@ static void test_read_write(void)
iob.Information = -1;
offset.QuadPart = (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */;
status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, "DCBA", 4, &offset, NULL);
todo_wine ok(status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
ok(status == STATUS_PENDING || broken(status == STATUS_SUCCESS) /* before Vista */,
"expected STATUS_PENDING, got %#x.\n", status);
if (status == STATUS_PENDING)
{
......@@ -4626,7 +4626,7 @@ static void test_read_write(void)
bytes = 0;
SetLastError(0xdeadbeef);
ret = WriteFile(hfile, "ABCD", 4, &bytes, &ovl);
todo_wine ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* before Vista */,
ok((!ret && GetLastError() == ERROR_IO_PENDING) || broken(ret) /* before Vista */,
"Unexpected result %#x, GetLastError() %u.\n", ret, GetLastError());
if (!ret)
{
......
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