Commit ca4ae96f authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

NtReadFile: now returning correct status in NtReadFile for EOF

conditions (on files) and broken pipe (on named pipes).
parent c9e02e11
......@@ -757,7 +757,7 @@ static void test_CreatePipe(void)
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from broken pipe withe with pending data failed\n");
ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes instead of %d\n", read, sizeof(PIPENAME));
/* But now we need to get informed that the pipe is closed */
todo_wine ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
}
START_TEST(pipe)
......
......@@ -589,8 +589,16 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
else io_status->u.Status = FILE_GetNtStatus();
break;
}
if (io_status->u.Status == STATUS_SUCCESS && io_status->Information == 0)
{
struct stat st;
if (fstat( unix_handle, &st ) != -1 && S_ISSOCK( st.st_mode ))
io_status->u.Status = STATUS_PIPE_BROKEN;
else
io_status->u.Status = STATUS_END_OF_FILE;
}
wine_server_release_fd( hFile, unix_handle );
TRACE("= 0x%08lx\n", io_status->u.Status);
TRACE("= 0x%08lx (%lu)\n", io_status->u.Status, io_status->Information);
return io_status->u.Status;
}
......
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