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
7bee1d35
Commit
7bee1d35
authored
May 31, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Reimplement WSASendTo along the lines of NtWriteFile.
parent
c0bf8e7d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
61 deletions
+69
-61
socket.c
dlls/ws2_32/socket.c
+69
-61
No files found.
dlls/ws2_32/socket.c
View file @
7bee1d35
...
...
@@ -2691,9 +2691,8 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
lpCompletionRoutine
)
{
unsigned
int
i
,
options
;
int
n
,
fd
,
err
=
WSAENOTSOCK
,
ret
;
int
n
,
fd
,
err
;
struct
iovec
iovec
[
WS_MSG_MAXIOVLEN
];
struct
ws2_async
*
wsa
;
IO_STATUS_BLOCK
*
iosb
;
TRACE
(
"socket %04lx, wsabuf %p, nbufs %d, flags %d, to %p, tolen %d, ovl %p, func %p
\n
"
,
...
...
@@ -2723,10 +2722,23 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
iovec
[
i
].
iov_len
=
lpBuffers
[
i
].
len
;
}
if
(
(
lpOverlapped
||
lpCompletionRoutine
)
&&
for
(;;)
{
n
=
WS2_send
(
fd
,
iovec
,
dwBufferCount
,
to
,
tolen
,
dwFlags
);
if
(
n
!=
-
1
||
errno
!=
EINTR
)
break
;
}
if
(
n
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
{
err
=
wsaErrno
();
goto
error
;
}
if
((
lpOverlapped
||
lpCompletionRoutine
)
&&
!
(
options
&
(
FILE_SYNCHRONOUS_IO_ALERT
|
FILE_SYNCHRONOUS_IO_NONALERT
)))
{
wsa
=
WS2_make_async
(
s
,
ws2m_write
,
iovec
,
dwBufferCount
,
struct
ws2_async
*
wsa
=
WS2_make_async
(
s
,
ws2m_write
,
iovec
,
dwBufferCount
,
&
dwFlags
,
(
struct
WS_sockaddr
*
)
to
,
&
tolen
,
lpOverlapped
,
lpCompletionRoutine
,
&
iosb
);
if
(
!
wsa
)
...
...
@@ -2734,94 +2746,90 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
err
=
WSAEFAULT
;
goto
error
;
}
release_sock_fd
(
s
,
fd
);
if
((
ret
=
ws2_queue_async
(
wsa
,
iosb
))
!=
STATUS_PENDING
)
{
err
=
NtStatusToWSAError
(
ret
);
iosb
->
u
.
Status
=
STATUS_PENDING
;
iosb
->
Information
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
wsa
);
goto
error
;
SERVER_START_REQ
(
register_async
)
{
req
->
handle
=
wsa
->
hSocket
;
req
->
type
=
ASYNC_TYPE_WRITE
;
req
->
async
.
callback
=
WS2_async_send
;
req
->
async
.
iosb
=
iosb
;
req
->
async
.
arg
=
wsa
;
req
->
async
.
event
=
lpCompletionRoutine
?
0
:
lpOverlapped
->
hEvent
;
err
=
wine_server_call
(
req
);
}
release_sock_fd
(
s
,
fd
)
;
SERVER_END_REQ
;
/* Try immediate completion */
if
(
lpOverlapped
)
{
if
(
WSAGetOverlappedResult
(
s
,
lpOverlapped
,
lpNumberOfBytesSent
,
FALSE
,
&
dwFlags
)
)
return
0
;
if
(
err
==
STATUS_PENDING
)
NtCurrentTeb
()
->
num_async_io
++
;
else
ws2_async_terminate
(
wsa
,
iosb
,
err
,
0
);
if
(
(
err
=
WSAGetLastError
())
!=
WSA_IO_INCOMPLETE
)
WSASetLastError
(
NtStatusToWSAError
(
err
));
return
SOCKET_ERROR
;
}
WSASetLastError
(
WSA_IO_PENDING
);
return
SOCKET_ERROR
;
}
*
lpNumberOfBytesSent
=
0
;
if
(
_is_blocking
(
s
)
)
{
/* On a blocking non-overlapped stream socket,
* sending blocks until the entire buffer is sent. */
struct
iovec
*
piovec
=
iovec
;
int
finish_time
=
GET_SNDTIMEO
(
fd
);
if
(
finish_time
>=
0
)
finish_time
+=
GetTickCount
();
while
(
dwBufferCount
>
0
)
DWORD
timeout_start
=
GetTickCount
();
unsigned
int
first_buff
=
0
;
*
lpNumberOfBytesSent
=
0
;
while
(
first_buff
<
dwBufferCount
)
{
int
timeout
;
if
(
finish_time
>=
0
)
struct
pollfd
pfd
;
int
timeout
=
GET_SNDTIMEO
(
fd
);
if
(
n
>
0
)
{
timeout
=
finish_time
-
GetTickCount
();
if
(
timeout
<
0
)
timeout
=
0
;
}
*
lpNumberOfBytesSent
+=
n
;
if
(
iovec
[
first_buff
].
iov_len
>
n
)
iovec
[
first_buff
].
iov_len
-=
n
;
else
timeout
=
finish_time
;
/* FIXME: exceptfds? */
if
(
!
do_block
(
fd
,
POLLOUT
,
timeout
))
{
err
=
WSAETIMEDOUT
;
goto
error
;
/* msdn says a timeout in send is fatal */
{
while
(
n
>
0
)
n
-=
iovec
[
first_buff
++
].
iov_len
;
if
(
first_buff
>=
dwBufferCount
)
break
;
}
}
n
=
WS2_send
(
fd
,
piovec
,
dwBufferCount
,
to
,
tolen
,
dwFlags
);
if
(
n
==
-
1
)
if
(
timeout
!=
-
1
)
{
err
=
wsaErrno
();
goto
error
;
timeout
-=
timeout_start
-
GetTickCount
();
if
(
timeout
<
0
)
timeout
=
0
;
}
*
lpNumberOfBytesSent
+=
n
;
while
(
n
>
0
)
{
if
(
piovec
->
iov_len
>
n
)
pfd
.
fd
=
fd
;
pfd
.
events
=
POLLOUT
;
if
(
!
timeout
||
!
poll
(
&
pfd
,
1
,
timeout
))
{
piovec
->
iov_base
=
(
char
*
)
piovec
->
iov_base
+
n
;
piovec
->
iov_len
-=
n
;
n
=
0
;
err
=
WSAETIMEDOUT
;
goto
error
;
/* msdn says a timeout in send is fatal */
}
else
n
=
WS2_send
(
fd
,
iovec
+
first_buff
,
dwBufferCount
-
first_buff
,
to
,
tolen
,
dwFlags
);
if
(
n
==
-
1
&&
errno
!=
EAGAIN
&&
errno
!=
EINTR
)
{
n
-=
piovec
->
iov_len
;
--
dwBufferCount
;
++
piovec
;
}
err
=
wsaErrno
();
goto
error
;
}
}
}
else
else
/* non-blocking */
{
n
=
WS2_send
(
fd
,
iovec
,
dwBufferCount
,
to
,
tolen
,
dwFlags
);
if
(
n
==
-
1
)
{
err
=
wsaErrno
();
if
(
err
==
WSAEWOULDBLOCK
)
_enable_event
(
SOCKET2HANDLE
(
s
),
FD_WRITE
,
0
,
0
);
if
(
n
==
-
1
)
{
err
=
WSAEWOULDBLOCK
;
goto
error
;
}
else
_enable_event
(
SOCKET2HANDLE
(
s
),
FD_WRITE
,
0
,
0
);
*
lpNumberOfBytesSent
=
n
;
}
...
...
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