mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:10:22 +00:00
Windows Sockets: handle client socket close correctly.
When the client closes the socket on which it is listening GetQueuedCompletionsStatus can return with the error ERROR_NETNAME_DELETED. R=sgjesse@google.com BUG=2 TEST=EchoServerTest.dart Review URL: https://chromereviews.googleplex.com/3573014 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@209 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
5529bf7abe
commit
4914d6c9c6
|
@ -735,22 +735,22 @@ static unsigned int __stdcall EventHandlerThread(void* args) {
|
|||
} else if (!ok) {
|
||||
// If GetQueuedCompletionStatus return false and overlapped is
|
||||
// not NULL then it did dequeue a request which failed.
|
||||
if (overlapped != NULL) {
|
||||
// Treat ERROR_CONNECTION_ABORTED as connection closed.
|
||||
// The error ERROR_OPERATION_ABORTED is set for pending
|
||||
// accept requests for a listen socket which is closed.
|
||||
if (GetLastError() == ERROR_CONNECTION_ABORTED ||
|
||||
GetLastError() == ERROR_OPERATION_ABORTED) {
|
||||
ASSERT(bytes == 0);
|
||||
handler->HandleIOCompletion(bytes, key, overlapped);
|
||||
} else {
|
||||
printf("After GetQueuedCompletionStatus %d\n", GetLastError());
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
// Treat ERROR_CONNECTION_ABORTED as connection closed.
|
||||
// The error ERROR_OPERATION_ABORTED is set for pending
|
||||
// accept requests for a listen socket which is closed.
|
||||
// ERROR_NETNAME_DELETED occurs when the client closes
|
||||
// the socket it is reading from.
|
||||
DWORD last_error = GetLastError();
|
||||
if (last_error == ERROR_CONNECTION_ABORTED ||
|
||||
last_error == ERROR_OPERATION_ABORTED ||
|
||||
last_error == ERROR_NETNAME_DELETED) {
|
||||
ASSERT(bytes == 0);
|
||||
handler->HandleIOCompletion(bytes, key, overlapped);
|
||||
} else {
|
||||
printf("After GetQueuedCompletionStatus %d\n", GetLastError());
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
} else if (key == NULL) {
|
||||
// A key of NULL signals an interrupt message.
|
||||
InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(overlapped);
|
||||
|
|
|
@ -27,8 +27,6 @@ Process*: Skip # Bug 1
|
|||
# Windows implementation of Process is still pending.
|
||||
Process*: Skip
|
||||
EchoServerStreamReadUntilTest: Skip # Bug 5414270
|
||||
EchoServerStreamTest: Pass || Crash # Bug 2
|
||||
EchoServerTest: Pass || Crash # Bug 2
|
||||
|
||||
|
||||
[ $arch == dartium ]
|
||||
|
|
|
@ -85,6 +85,8 @@ class EchoServerGame {
|
|||
_socket = new Socket(EchoServer.HOST, _port);
|
||||
if (_socket !== null) {
|
||||
_socket.setConnectHandler(connectHandler);
|
||||
} else {
|
||||
Expect.fail("socket creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ class EchoServerGame {
|
|||
_socket = new Socket(EchoServer.HOST, _port);
|
||||
if (_socket !== null) {
|
||||
_socket.setConnectHandler(connectHandler);
|
||||
} else {
|
||||
Expect.fail("socket creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue