Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6dcb280b
Commit
6dcb280b
authored
Apr 10, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Simplify the async read/write code now that most of the work is done in the server.
parent
72bff2e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
58 deletions
+63
-58
file.c
dlls/ntdll/file.c
+63
-58
No files found.
dlls/ntdll/file.c
View file @
6dcb280b
...
...
@@ -236,57 +236,24 @@ NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIB
/***********************************************************************
* Asynchronous file I/O *
*/
static
NTSTATUS
FILE_AsyncReadService
(
void
*
,
PIO_STATUS_BLOCK
,
NTSTATUS
);
static
NTSTATUS
FILE_AsyncWriteService
(
void
*
,
PIO_STATUS_BLOCK
,
NTSTATUS
);
typedef
struct
async_fileio
typedef
struct
{
HANDLE
handle
;
PIO_APC_ROUTINE
apc
;
void
*
apc_user
;
char
*
buffer
;
unsigned
int
already
;
unsigned
int
count
;
BOOL
avail_mode
;
HANDLE
event
;
}
async_fileio
;
}
async_fileio_read
;
static
void
fileio_terminate
(
async_fileio
*
fileio
,
IO_STATUS_BLOCK
*
iosb
,
NTSTATUS
status
)
typedef
struct
{
TRACE
(
"data: %p
\n
"
,
fileio
);
iosb
->
u
.
Status
=
status
;
iosb
->
Information
=
fileio
->
already
;
RtlFreeHeap
(
GetProcessHeap
(),
0
,
fileio
);
}
static
ULONG
fileio_queue_async
(
async_fileio
*
fileio
,
IO_STATUS_BLOCK
*
iosb
,
BOOL
do_read
)
{
NTSTATUS
status
;
SERVER_START_REQ
(
register_async
)
{
req
->
handle
=
fileio
->
handle
;
req
->
async
.
callback
=
do_read
?
FILE_AsyncReadService
:
FILE_AsyncWriteService
;
req
->
async
.
iosb
=
iosb
;
req
->
async
.
arg
=
fileio
;
req
->
async
.
apc
=
fileio
->
apc
;
req
->
async
.
apc_arg
=
fileio
->
apc_user
;
req
->
async
.
event
=
fileio
->
event
;
req
->
type
=
do_read
?
ASYNC_TYPE_READ
:
ASYNC_TYPE_WRITE
;
req
->
count
=
(
fileio
->
count
<
fileio
->
already
)
?
0
:
fileio
->
count
-
fileio
->
already
;
status
=
wine_server_call
(
req
);
}
SERVER_END_REQ
;
HANDLE
handle
;
const
char
*
buffer
;
unsigned
int
already
;
unsigned
int
count
;
}
async_fileio_write
;
if
(
status
!=
STATUS_PENDING
)
fileio_terminate
(
fileio
,
iosb
,
status
);
else
NtCurrentTeb
()
->
num_async_io
++
;
return
status
;
}
/***********************************************************************
* FILE_GetNtStatus(void)
...
...
@@ -339,7 +306,7 @@ NTSTATUS FILE_GetNtStatus(void)
*/
static
NTSTATUS
FILE_AsyncReadService
(
void
*
user
,
PIO_STATUS_BLOCK
iosb
,
NTSTATUS
status
)
{
async_fileio
*
fileio
=
(
async_fileio
*
)
user
;
async_fileio
_read
*
fileio
=
user
;
int
fd
,
needs_close
,
result
;
TRACE
(
"%p %p 0x%x
\n
"
,
iosb
,
fileio
->
buffer
,
status
);
...
...
@@ -394,7 +361,12 @@ static NTSTATUS FILE_AsyncReadService(void *user, PIO_STATUS_BLOCK iosb, NTSTATU
if
(
fileio
->
already
)
status
=
STATUS_SUCCESS
;
break
;
}
if
(
status
!=
STATUS_PENDING
)
fileio_terminate
(
fileio
,
iosb
,
status
);
if
(
status
!=
STATUS_PENDING
)
{
iosb
->
u
.
Status
=
status
;
iosb
->
Information
=
fileio
->
already
;
RtlFreeHeap
(
GetProcessHeap
(),
0
,
fileio
);
}
return
status
;
}
...
...
@@ -580,7 +552,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
if
(
flags
&
FD_FLAG_OVERLAPPED
)
{
async_fileio
*
fileio
;
async_fileio
_read
*
fileio
;
if
(
total
&&
(
flags
&
FD_FLAG_AVAILABLE
))
{
...
...
@@ -588,7 +560,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
goto
done
;
}
if
(
!
(
fileio
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
async_
fileio
))))
if
(
!
(
fileio
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
*
fileio
))))
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
...
...
@@ -596,12 +568,26 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
fileio
->
handle
=
hFile
;
fileio
->
already
=
total
;
fileio
->
count
=
length
;
fileio
->
apc
=
apc
;
fileio
->
apc_user
=
apc_user
;
fileio
->
buffer
=
buffer
;
fileio
->
avail_mode
=
(
flags
&
FD_FLAG_AVAILABLE
);
fileio
->
event
=
hEvent
;
status
=
fileio_queue_async
(
fileio
,
io_status
,
TRUE
);
SERVER_START_REQ
(
register_async
)
{
req
->
handle
=
hFile
;
req
->
type
=
ASYNC_TYPE_READ
;
req
->
count
=
length
;
req
->
async
.
callback
=
FILE_AsyncReadService
;
req
->
async
.
iosb
=
io_status
;
req
->
async
.
arg
=
fileio
;
req
->
async
.
apc
=
apc
;
req
->
async
.
apc_arg
=
apc_user
;
req
->
async
.
event
=
hEvent
;
status
=
wine_server_call
(
req
);
}
SERVER_END_REQ
;
if
(
status
!=
STATUS_PENDING
)
RtlFreeHeap
(
GetProcessHeap
(),
0
,
fileio
);
else
NtCurrentTeb
()
->
num_async_io
++
;
goto
done
;
}
else
/* synchronous read, wait for the fd to become ready */
...
...
@@ -662,7 +648,7 @@ done:
*/
static
NTSTATUS
FILE_AsyncWriteService
(
void
*
user
,
IO_STATUS_BLOCK
*
iosb
,
NTSTATUS
status
)
{
async_fileio
*
fileio
=
user
;
async_fileio
_write
*
fileio
=
user
;
int
result
,
fd
,
needs_close
;
enum
server_fd_type
type
;
...
...
@@ -701,7 +687,12 @@ static NTSTATUS FILE_AsyncWriteService(void *user, IO_STATUS_BLOCK *iosb, NTSTAT
if
(
fileio
->
already
)
status
=
STATUS_SUCCESS
;
break
;
}
if
(
status
!=
STATUS_PENDING
)
fileio_terminate
(
fileio
,
iosb
,
status
);
if
(
status
!=
STATUS_PENDING
)
{
iosb
->
u
.
Status
=
status
;
iosb
->
Information
=
fileio
->
already
;
RtlFreeHeap
(
GetProcessHeap
(),
0
,
fileio
);
}
return
status
;
}
...
...
@@ -799,9 +790,9 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
if
(
flags
&
FD_FLAG_OVERLAPPED
)
{
async_fileio
*
fileio
;
async_fileio
_write
*
fileio
;
if
(
!
(
fileio
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
async_
fileio
))))
if
(
!
(
fileio
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
*
fileio
))))
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
...
...
@@ -809,11 +800,25 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
fileio
->
handle
=
hFile
;
fileio
->
already
=
total
;
fileio
->
count
=
length
;
fileio
->
apc
=
apc
;
fileio
->
apc_user
=
apc_user
;
fileio
->
buffer
=
(
void
*
)
buffer
;
fileio
->
event
=
hEvent
;
status
=
fileio_queue_async
(
fileio
,
io_status
,
FALSE
);
fileio
->
buffer
=
buffer
;
SERVER_START_REQ
(
register_async
)
{
req
->
handle
=
hFile
;
req
->
type
=
ASYNC_TYPE_WRITE
;
req
->
count
=
length
;
req
->
async
.
callback
=
FILE_AsyncWriteService
;
req
->
async
.
iosb
=
io_status
;
req
->
async
.
arg
=
fileio
;
req
->
async
.
apc
=
apc
;
req
->
async
.
apc_arg
=
apc_user
;
req
->
async
.
event
=
hEvent
;
status
=
wine_server_call
(
req
);
}
SERVER_END_REQ
;
if
(
status
!=
STATUS_PENDING
)
RtlFreeHeap
(
GetProcessHeap
(),
0
,
fileio
);
else
NtCurrentTeb
()
->
num_async_io
++
;
goto
done
;
}
else
/* synchronous write, wait for the fd to become ready */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment