Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
9ca4285a
Commit
9ca4285a
authored
Apr 25, 2002
by
Martin Wilck
Committed by
Alexandre Julliard
Apr 25, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed ReadFile() semantics when reading asynchronously on sockets.
Provide more accurate status codes than STATUS_UNSUCCESSFUL.
parent
894b188f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
15 deletions
+65
-15
file.c
files/file.c
+62
-14
server_protocol.h
include/wine/server_protocol.h
+1
-0
protocol.def
server/protocol.def
+1
-0
sock.c
server/sock.c
+1
-1
No files found.
files/file.c
View file @
9ca4285a
...
...
@@ -115,6 +115,7 @@ typedef struct async_fileio
LPOVERLAPPED_COMPLETION_ROUTINE
completion_func
;
char
*
buffer
;
int
count
;
enum
fd_type
fd_type
;
}
async_fileio
;
static
DWORD
fileio_get_async_status
(
const
struct
async_private
*
ovp
)
...
...
@@ -209,6 +210,42 @@ int FILE_strncasecmp( const char *str1, const char *str2, int len )
/***********************************************************************
* FILE_GetNtStatus(void)
*
* Retrieve the Nt Status code from errno.
* Try to be consistent with FILE_SetDosError().
*/
DWORD
FILE_GetNtStatus
(
void
)
{
int
err
=
errno
;
DWORD
nt
;
TRACE
(
"errno = %d
\n
"
,
errno
);
switch
(
err
)
{
case
EAGAIN
:
nt
=
STATUS_SHARING_VIOLATION
;
break
;
case
EBADF
:
nt
=
STATUS_INVALID_HANDLE
;
break
;
case
ENOSPC
:
nt
=
STATUS_DISK_FULL
;
break
;
case
EPERM
:
case
EROFS
:
case
EACCES
:
nt
=
STATUS_ACCESS_DENIED
;
break
;
case
ENOENT
:
nt
=
STATUS_SHARING_VIOLATION
;
break
;
case
EISDIR
:
nt
=
STATUS_FILE_IS_A_DIRECTORY
;
break
;
case
EMFILE
:
case
ENFILE
:
nt
=
STATUS_NO_MORE_FILES
;
break
;
case
EINVAL
:
case
ENOTEMPTY
:
nt
=
STATUS_DIRECTORY_NOT_EMPTY
;
break
;
case
EPIPE
:
nt
=
STATUS_PIPE_BROKEN
;
break
;
case
ENOEXEC
:
/* ?? */
case
ESPIPE
:
/* ?? */
case
EEXIST
:
/* ?? */
default:
FIXME
(
"Converting errno %d to STATUS_UNSUCCESSFUL
\n
"
,
err
);
nt
=
STATUS_UNSUCCESSFUL
;
}
return
nt
;
}
/***********************************************************************
* FILE_SetDosError
*
* Set the DOS error code from errno.
...
...
@@ -1460,10 +1497,15 @@ static void FILE_AsyncReadService(async_private *ovp)
/* check to see if the data is ready (non-blocking) */
result
=
pread
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
,
OVERLAPPED_OFFSET
(
lpOverlapped
)
+
already
);
if
((
result
<
0
)
&&
(
errno
==
ESPIPE
))
if
(
fileio
->
fd_type
==
FD_TYPE_SOCKET
)
result
=
read
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
);
else
{
result
=
pread
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
,
OVERLAPPED_OFFSET
(
lpOverlapped
)
+
already
);
if
((
result
<
0
)
&&
(
errno
==
ESPIPE
))
result
=
read
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
);
}
if
(
(
result
<
0
)
&&
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
)))
{
...
...
@@ -1475,18 +1517,17 @@ static void FILE_AsyncReadService(async_private *ovp)
/* check to see if the transfer is complete */
if
(
result
<
0
)
{
TRACE
(
"read returned errno %d
\n
"
,
errno
);
r
=
STATUS_UNSUCCESSFUL
;
r
=
FILE_GetNtStatus
();
goto
async_end
;
}
lpOverlapped
->
InternalHigh
+=
result
;
TRACE
(
"read %d more bytes %ld/%d so far
\n
"
,
result
,
lpOverlapped
->
InternalHigh
,
fileio
->
count
);
if
(
lpOverlapped
->
InternalHigh
<
fileio
->
count
)
r
=
STATUS_PENDING
;
else
if
(
lpOverlapped
->
InternalHigh
>=
fileio
->
count
||
fileio
->
fd_type
==
FD_TYPE_SOCKET
)
r
=
STATUS_SUCCESS
;
else
r
=
STATUS_PENDING
;
async_end:
lpOverlapped
->
Internal
=
r
;
...
...
@@ -1545,6 +1586,7 @@ static BOOL FILE_ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
ovp
->
count
=
bytesToRead
;
ovp
->
completion_func
=
lpCompletionRoutine
;
ovp
->
buffer
=
buffer
;
ovp
->
fd_type
=
type
;
return
!
register_new_async
(
&
ovp
->
async
);
...
...
@@ -1684,10 +1726,15 @@ static void FILE_AsyncWriteService(struct async_private *ovp)
/* write some data (non-blocking) */
result
=
pwrite
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
,
OVERLAPPED_OFFSET
(
lpOverlapped
)
+
already
);
if
((
result
<
0
)
&&
(
errno
==
ESPIPE
))
if
(
fileio
->
fd_type
==
FD_TYPE_SOCKET
)
result
=
write
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
);
else
{
result
=
pwrite
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
,
OVERLAPPED_OFFSET
(
lpOverlapped
)
+
already
);
if
((
result
<
0
)
&&
(
errno
==
ESPIPE
))
result
=
write
(
ovp
->
fd
,
&
fileio
->
buffer
[
already
],
fileio
->
count
-
already
);
}
if
(
(
result
<
0
)
&&
((
errno
==
EAGAIN
)
||
(
errno
==
EINTR
)))
{
...
...
@@ -1698,7 +1745,7 @@ static void FILE_AsyncWriteService(struct async_private *ovp)
/* check to see if the transfer is complete */
if
(
result
<
0
)
{
r
=
STATUS_UNSUCCESSFUL
;
r
=
FILE_GetNtStatus
()
;
goto
async_end
;
}
...
...
@@ -1728,8 +1775,8 @@ static BOOL FILE_WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
int
flags
;
enum
fd_type
type
;
TRACE
(
"file %d to buf %p num %ld %p func %p
stub
\n
"
,
hFile
,
buffer
,
bytesToWrite
,
overlapped
,
lpCompletionRoutine
);
TRACE
(
"file %d to buf %p num %ld %p func %p
handle %d
\n
"
,
hFile
,
buffer
,
bytesToWrite
,
overlapped
,
lpCompletionRoutine
,
hEvent
);
if
(
overlapped
==
NULL
)
{
...
...
@@ -1767,6 +1814,7 @@ static BOOL FILE_WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
ovp
->
buffer
=
(
LPVOID
)
buffer
;
ovp
->
count
=
bytesToWrite
;
ovp
->
completion_func
=
lpCompletionRoutine
;
ovp
->
fd_type
=
type
;
return
!
register_new_async
(
&
ovp
->
async
);
...
...
include/wine/server_protocol.h
View file @
9ca4285a
...
...
@@ -791,6 +791,7 @@ enum fd_type
FD_TYPE_INVALID
,
FD_TYPE_DEFAULT
,
FD_TYPE_CONSOLE
,
FD_TYPE_SOCKET
,
FD_TYPE_SMB
};
#define FD_FLAG_OVERLAPPED 0x01
...
...
server/protocol.def
View file @
9ca4285a
...
...
@@ -608,6 +608,7 @@ enum fd_type
FD_TYPE_INVALID,
FD_TYPE_DEFAULT,
FD_TYPE_CONSOLE,
FD_TYPE_SOCKET,
FD_TYPE_SMB
};
#define FD_FLAG_OVERLAPPED 0x01
...
...
server/sock.c
View file @
9ca4285a
...
...
@@ -421,7 +421,7 @@ static int sock_get_info( struct object *obj, struct get_file_info_reply *reply,
if
(
sock
->
flags
&
WSA_FLAG_OVERLAPPED
)
*
flags
|=
FD_FLAG_OVERLAPPED
;
if
(
!
(
sock
->
state
&
FD_READ
)
)
*
flags
|=
FD_FLAG_RECV_SHUTDOWN
;
if
(
!
(
sock
->
state
&
FD_WRITE
)
)
*
flags
|=
FD_FLAG_SEND_SHUTDOWN
;
return
FD_TYPE_
DEFAUL
T
;
return
FD_TYPE_
SOCKE
T
;
}
static
void
sock_queue_async
(
struct
object
*
obj
,
void
*
ptr
,
unsigned
int
status
,
int
type
,
int
count
)
...
...
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