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

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 12646007: Fix file descriptor leak in event handler implementation. When shutting down an isolate, we did not… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/platform/thread_win.h » ('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 a10dd04217902328b0fcbe77953bf7235d4115b9..cb193a640ae6145aea6ebf7c0c87275473572ffd 100644
--- a/runtime/bin/eventhandler_win.cc
+++ b/runtime/bin/eventhandler_win.cc
@@ -889,6 +889,11 @@ EventHandlerImplementation::EventHandlerImplementation() {
}
+EventHandlerImplementation::~EventHandlerImplementation() {
+ CloseHandle(completion_port_);
+}
+
+
DWORD EventHandlerImplementation::GetTimeout() {
if (timeout_ == kInfinityTimeout) {
return kInfinityTimeout;
@@ -914,15 +919,15 @@ void EventHandlerImplementation::SendData(intptr_t id,
void EventHandlerImplementation::EventHandlerEntry(uword args) {
- EventHandlerImplementation* handler =
- reinterpret_cast<EventHandlerImplementation*>(args);
- ASSERT(handler != NULL);
- while (!handler->shutdown_) {
+ EventHandler* handler = reinterpret_cast<EventHandler*>(args);
+ EventHandlerImplementation* handler_impl = &handler->delegate_;
+ ASSERT(handler_impl != NULL);
+ while (!handler_impl->shutdown_) {
DWORD bytes;
ULONG_PTR key;
OVERLAPPED* overlapped;
- intptr_t millis = handler->GetTimeout();
- BOOL ok = GetQueuedCompletionStatus(handler->completion_port(),
+ intptr_t millis = handler_impl->GetTimeout();
+ BOOL ok = GetQueuedCompletionStatus(handler_impl->completion_port(),
&bytes,
&key,
&overlapped,
@@ -934,7 +939,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
UNREACHABLE();
} else {
// Timeout is signalled by false result and NULL in overlapped.
- handler->HandleTimeout();
+ handler_impl->HandleTimeout();
}
} else if (!ok) {
// Treat ERROR_CONNECTION_ABORTED as connection closed.
@@ -948,26 +953,27 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
last_error == ERROR_NETNAME_DELETED ||
last_error == ERROR_BROKEN_PIPE) {
ASSERT(bytes == 0);
- handler->HandleIOCompletion(bytes, key, overlapped);
+ handler_impl->HandleIOCompletion(bytes, key, overlapped);
} else {
ASSERT(bytes == 0);
- handler->HandleIOCompletion(-1, key, overlapped);
+ handler_impl->HandleIOCompletion(-1, key, overlapped);
}
} else if (key == NULL) {
// A key of NULL signals an interrupt message.
InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(overlapped);
- handler->HandleInterrupt(msg);
+ handler_impl->HandleInterrupt(msg);
delete msg;
} else {
- handler->HandleIOCompletion(bytes, key, overlapped);
+ handler_impl->HandleIOCompletion(bytes, key, overlapped);
}
}
+ delete handler;
}
-void EventHandlerImplementation::Start() {
+void EventHandlerImplementation::Start(EventHandler* handler) {
int result = dart::Thread::Start(EventHandlerEntry,
- reinterpret_cast<uword>(this));
+ reinterpret_cast<uword>(handler));
if (result != 0) {
FATAL1("Failed to start event handler thread %d", result);
}
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/platform/thread_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698