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
e39dca6a
Commit
e39dca6a
authored
Mar 22, 2007
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Mar 22, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: WSASendTo should always re-enable the FD_WRITE event.
parent
df605c0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
0 deletions
+143
-0
socket.c
dlls/ws2_32/socket.c
+2
-0
sock.c
dlls/ws2_32/tests/sock.c
+141
-0
No files found.
dlls/ws2_32/socket.c
View file @
e39dca6a
...
...
@@ -2930,6 +2930,8 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
_enable_event
(
SOCKET2HANDLE
(
s
),
FD_WRITE
,
0
,
0
);
goto
err_free
;
}
else
_enable_event
(
SOCKET2HANDLE
(
s
),
FD_WRITE
,
0
,
0
);
*
lpNumberOfBytesSent
=
n
;
}
...
...
dlls/ws2_32/tests/sock.c
View file @
e39dca6a
...
...
@@ -1729,6 +1729,146 @@ end:
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
static
void
test_write_events
(
void
)
{
SOCKET
src
=
INVALID_SOCKET
;
SOCKET
server
=
INVALID_SOCKET
;
SOCKET
dst
=
INVALID_SOCKET
;
HANDLE
hThread
=
NULL
;
HANDLE
hEvent
=
INVALID_HANDLE_VALUE
;
struct
sockaddr_in
addr
;
int
len
;
u_long
one
=
1
;
int
ret
;
src
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
src
==
INVALID_SOCKET
)
{
ok
(
0
,
"socket failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
server
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
server
==
INVALID_SOCKET
)
{
ok
(
0
,
"socket failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
inet_addr
(
"127.0.0.1"
);
ret
=
bind
(
server
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
ret
!=
0
)
{
ok
(
0
,
"bind failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
len
=
sizeof
(
addr
);
ret
=
getsockname
(
server
,
(
struct
sockaddr
*
)
&
addr
,
&
len
);
if
(
ret
!=
0
)
{
ok
(
0
,
"getsockname failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
ret
=
listen
(
server
,
1
);
if
(
ret
!=
0
)
{
ok
(
0
,
"listen failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
ret
=
connect
(
src
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
ret
!=
0
)
{
ok
(
0
,
"connect failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
len
=
sizeof
(
addr
);
dst
=
accept
(
server
,
(
struct
sockaddr
*
)
&
addr
,
&
len
);
if
(
dst
==
INVALID_SOCKET
)
{
ok
(
0
,
"accept failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
hThread
=
CreateThread
(
NULL
,
0
,
drain_socket_thread
,
&
dst
,
0
,
NULL
);
if
(
hThread
==
NULL
)
{
ok
(
0
,
"CreateThread failed, error %d
\n
"
,
GetLastError
());
goto
end
;
}
hEvent
=
CreateEventW
(
NULL
,
FALSE
,
TRUE
,
NULL
);
if
(
hEvent
==
INVALID_HANDLE_VALUE
)
{
ok
(
0
,
"CreateEventW failed, error %d
\n
"
,
GetLastError
());
goto
end
;
}
ret
=
ioctlsocket
(
src
,
FIONBIO
,
&
one
);
if
(
ret
)
{
ok
(
0
,
"ioctlsocket failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
ret
=
WSAEventSelect
(
src
,
hEvent
,
FD_WRITE
|
FD_CLOSE
);
if
(
ret
)
{
ok
(
0
,
"WSAEventSelect failed, error %d
\n
"
,
ret
);
goto
end
;
}
for
(
len
=
100
;
len
>
0
;
--
len
)
{
WSANETWORKEVENTS
netEvents
;
DWORD
dwRet
=
WaitForSingleObject
(
hEvent
,
5000
);
if
(
dwRet
!=
WAIT_OBJECT_0
)
{
ok
(
0
,
"WaitForSingleObject failed, error %d
\n
"
,
dwRet
);
goto
end
;
}
ret
=
WSAEnumNetworkEvents
(
src
,
NULL
,
&
netEvents
);
if
(
ret
)
{
ok
(
0
,
"WSAEnumNetworkEvents failed, error %d
\n
"
,
ret
);
goto
end
;
}
if
(
netEvents
.
lNetworkEvents
&
FD_WRITE
)
{
ret
=
send
(
src
,
"a"
,
1
,
0
);
if
(
ret
<
0
&&
WSAGetLastError
()
!=
WSAEWOULDBLOCK
)
{
ok
(
0
,
"send failed, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
}
if
(
netEvents
.
lNetworkEvents
&
FD_CLOSE
)
{
ok
(
0
,
"unexpected close
\n
"
);
goto
end
;
}
}
end:
if
(
src
!=
INVALID_SOCKET
)
closesocket
(
src
);
if
(
server
!=
INVALID_SOCKET
)
closesocket
(
server
);
if
(
dst
!=
INVALID_SOCKET
)
closesocket
(
dst
);
if
(
hThread
!=
NULL
)
CloseHandle
(
hThread
);
CloseHandle
(
hEvent
);
}
/**************** Main program ***************/
START_TEST
(
sock
)
...
...
@@ -1763,6 +1903,7 @@ START_TEST( sock )
test_inet_addr
();
test_send
();
test_write_events
();
Exit
();
}
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