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

Unified Diff: runtime/bin/eventhandler_macos.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_macos.h ('k') | runtime/bin/eventhandler_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_macos.cc
diff --git a/runtime/bin/eventhandler_macos.cc b/runtime/bin/eventhandler_macos.cc
index 91c3bf70a1b2100aba3d591640a0310400f4fcc6..5972cfba771e80b60619676ed5bb7898e5edd43c 100644
--- a/runtime/bin/eventhandler_macos.cc
+++ b/runtime/bin/eventhandler_macos.cc
@@ -146,6 +146,7 @@ EventHandlerImplementation::EventHandlerImplementation()
EventHandlerImplementation::~EventHandlerImplementation() {
+ VOID_TEMP_FAILURE_RETRY(close(kqueue_fd_));
VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0]));
VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1]));
}
@@ -370,11 +371,11 @@ void EventHandlerImplementation::HandleTimeout() {
void EventHandlerImplementation::EventHandlerEntry(uword args) {
static const intptr_t kMaxEvents = 16;
struct kevent events[kMaxEvents];
- EventHandlerImplementation* handler =
- reinterpret_cast<EventHandlerImplementation*>(args);
- ASSERT(handler != NULL);
- while (!handler->shutdown_) {
- intptr_t millis = handler->GetTimeout();
+ EventHandler* handler = reinterpret_cast<EventHandler*>(args);
+ EventHandlerImplementation* handler_impl = &handler->delegate_;
+ ASSERT(handler_impl != NULL);
+ while (!handler_impl->shutdown_) {
+ intptr_t millis = handler_impl->GetTimeout();
// NULL pointer timespec for infinite timeout.
ASSERT(kInfinityTimeout < 0);
struct timespec* timeout = NULL;
@@ -384,7 +385,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
ts.tv_nsec = (millis - (ts.tv_sec * 1000)) * 1000000;
timeout = &ts;
}
- intptr_t result = TEMP_FAILURE_RETRY(kevent(handler->kqueue_fd_,
+ intptr_t result = TEMP_FAILURE_RETRY(kevent(handler_impl->kqueue_fd_,
NULL,
0,
events,
@@ -393,17 +394,18 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
if (result == -1) {
FATAL1("kevent failed %s\n", strerror(errno));
} else {
- handler->HandleTimeout();
- handler->HandleEvents(events, result);
+ handler_impl->HandleTimeout();
+ handler_impl->HandleEvents(events, result);
}
}
+ delete handler;
}
-void EventHandlerImplementation::Start() {
+void EventHandlerImplementation::Start(EventHandler* handler) {
int result =
dart::Thread::Start(&EventHandlerImplementation::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_macos.h ('k') | runtime/bin/eventhandler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698