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
a0c810c1
Commit
a0c810c1
authored
Jan 24, 2011
by
Mike Kaplinskiy
Committed by
Alexandre Julliard
Jan 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Add a test for an overlapped send.
parent
997a6813
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
3 deletions
+66
-3
sock.c
dlls/ws2_32/tests/sock.c
+66
-3
No files found.
dlls/ws2_32/tests/sock.c
View file @
a0c810c1
...
...
@@ -2793,8 +2793,13 @@ static void test_send(void)
HANDLE
hThread
=
NULL
;
const
int
buflen
=
1024
*
1024
;
char
*
buffer
=
NULL
;
int
ret
;
DWORD
id
;
int
ret
,
i
,
zero
=
0
;
WSABUF
buf
;
OVERLAPPED
ov
;
BOOL
bret
;
DWORD
id
,
bytes_sent
,
dwRet
;
memset
(
&
ov
,
0
,
sizeof
(
ov
));
if
(
tcp_socketpair
(
&
src
,
&
dst
)
!=
0
)
{
...
...
@@ -2802,6 +2807,11 @@ static void test_send(void)
return
;
}
set_blocking
(
dst
,
FALSE
);
/* force disable buffering so we can get a pending overlapped request */
ret
=
setsockopt
(
dst
,
SOL_SOCKET
,
SO_SNDBUF
,
(
char
*
)
&
zero
,
sizeof
(
zero
));
ok
(
!
ret
,
"setsockopt SO_SNDBUF failed: %d - %d
\n
"
,
ret
,
GetLastError
());
hThread
=
CreateThread
(
NULL
,
0
,
drain_socket_thread
,
&
dst
,
0
,
&
id
);
if
(
hThread
==
NULL
)
{
...
...
@@ -2809,19 +2819,70 @@ static void test_send(void)
goto
end
;
}
buffer
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
buflen
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
buflen
);
if
(
buffer
==
NULL
)
{
ok
(
0
,
"HeapAlloc failed, error %d
\n
"
,
GetLastError
());
goto
end
;
}
/* fill the buffer with some nonsense */
for
(
i
=
0
;
i
<
buflen
;
++
i
)
{
buffer
[
i
]
=
(
char
)
i
;
}
ret
=
send
(
src
,
buffer
,
buflen
,
0
);
if
(
ret
>=
0
)
ok
(
ret
==
buflen
,
"send should have sent %d bytes, but it only sent %d
\n
"
,
buflen
,
ret
);
else
ok
(
0
,
"send failed, error %d
\n
"
,
WSAGetLastError
());
buf
.
buf
=
buffer
;
buf
.
len
=
buflen
;
ov
.
hEvent
=
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
ok
(
ov
.
hEvent
!=
NULL
,
"could not create event object, errno = %d
\n
"
,
GetLastError
());
if
(
!
ov
.
hEvent
)
goto
end
;
bytes_sent
=
0
;
ret
=
WSASend
(
dst
,
&
buf
,
1
,
&
bytes_sent
,
0
,
&
ov
,
NULL
);
todo_wine
ok
((
ret
==
SOCKET_ERROR
&&
GetLastError
()
==
ERROR_IO_PENDING
)
||
broken
(
bytes_sent
==
buflen
),
"Failed to start overlapped send %d - %d - %d/%d
\n
"
,
ret
,
WSAGetLastError
(),
bytes_sent
,
buflen
);
if
(
(
ret
!=
SOCKET_ERROR
||
GetLastError
()
!=
ERROR_IO_PENDING
)
&&
bytes_sent
<
buflen
)
goto
end
;
/* don't check for completion yet, we may need to drain the buffer while still sending */
set_blocking
(
src
,
FALSE
);
for
(
i
=
0
;
i
<
buflen
;
++
i
)
{
int
j
=
0
;
ret
=
recv
(
src
,
buffer
,
1
,
0
);
while
(
ret
==
SOCKET_ERROR
&&
GetLastError
()
==
WSAEWOULDBLOCK
&&
j
<
100
)
{
j
++
;
Sleep
(
50
);
ret
=
recv
(
src
,
buffer
,
1
,
0
);
}
ok
(
ret
==
1
,
"Failed to receive data %d - %d (got %d/%d)
\n
"
,
ret
,
GetLastError
(),
i
,
buflen
);
if
(
ret
!=
1
)
break
;
ok
(
buffer
[
0
]
==
(
char
)
i
,
"Received bad data at position %d
\n
"
,
i
);
}
dwRet
=
WaitForSingleObject
(
ov
.
hEvent
,
1000
);
ok
(
dwRet
==
WAIT_OBJECT_0
,
"Failed to wait for recv message: %d - %d
\n
"
,
dwRet
,
GetLastError
());
if
(
dwRet
==
WAIT_OBJECT_0
)
{
bret
=
GetOverlappedResult
((
HANDLE
)
dst
,
&
ov
,
&
bytes_sent
,
FALSE
);
ok
((
bret
&&
bytes_sent
==
buflen
)
||
broken
(
!
bret
&&
GetLastError
()
==
ERROR_IO_INCOMPLETE
)
/* win9x */
,
"Got %d instead of %d (%d - %d)
\n
"
,
bytes_sent
,
buflen
,
bret
,
GetLastError
());
}
end:
if
(
src
!=
INVALID_SOCKET
)
closesocket
(
src
);
...
...
@@ -2829,6 +2890,8 @@ end:
closesocket
(
dst
);
if
(
hThread
!=
NULL
)
CloseHandle
(
hThread
);
if
(
ov
.
hEvent
)
CloseHandle
(
ov
.
hEvent
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
...
...
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