Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 269003002: Fix crash in raw_secure_server_socket_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status file. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_win.cc
diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc
index 754a5b96d6bc1172a05c42ec059f1ee90780d9a5..7e1a2b33d96f2fe86e395926d108faa8084cba9b 100644
--- a/runtime/bin/eventhandler_win.cc
+++ b/runtime/bin/eventhandler_win.cc
@@ -334,6 +334,7 @@ bool Handle::IssueSendTo(struct sockaddr* sa, socklen_t sa_len) {
void Handle::HandleIssueError() {
DWORD error = GetLastError();
+ ASSERT(event_handler_ != NULL);
if (error == ERROR_BROKEN_PIPE) {
event_handler_->HandleClosed(this);
} else {
@@ -399,6 +400,7 @@ bool DirectoryWatchHandle::IssueRead() {
void SocketHandle::HandleIssueError() {
int error = WSAGetLastError();
+ ASSERT(event_handler_ != NULL);
if (error == WSAECONNRESET) {
event_handler_->HandleClosed(this);
} else {
@@ -502,6 +504,17 @@ void ListenSocket::AcceptComplete(OverlappedBuffer* buffer,
}
+static void DeleteIfClosed(Handle* handle) {
+ if (handle->IsClosed()) {
+ Dart_Port port = handle->port();
+ delete handle;
+ if (port != ILLEGAL_PORT) {
+ DartUtils::PostInt32(port, 1 << kDestroyedEvent);
+ }
+ }
+}
+
+
void ListenSocket::DoClose() {
closesocket(socket());
handle_ = INVALID_HANDLE_VALUE;
@@ -510,6 +523,7 @@ void ListenSocket::DoClose() {
ClientSocket *client = Accept();
if (client != NULL) {
client->Close();
+ DeleteIfClosed(client);
} else {
break;
}
@@ -955,18 +969,8 @@ void DatagramSocket::DoClose() {
}
-static void DeleteIfClosed(Handle* handle) {
- if (handle->IsClosed()) {
- Dart_Port port = handle->port();
- delete handle;
- if (port != ILLEGAL_PORT) {
- DartUtils::PostInt32(port, 1 << kDestroyedEvent);
- }
- }
-}
-
-
void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
+ ASSERT(this != NULL);
if (msg->id == kTimeoutId) {
// Change of timeout request. Just set the new timeout and port as the
// completion thread will use the new timeout value for its next wait.
@@ -1289,6 +1293,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
&key,
&overlapped,
static_cast<DWORD>(millis));
+
if (!ok && overlapped == NULL) {
if (GetLastError() == ERROR_ABANDONED_WAIT_0) {
// The completion port should never be closed.
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698