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

Unified Diff: runtime/bin/eventhandler_linux.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_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_linux.cc
diff --git a/runtime/bin/eventhandler_linux.cc b/runtime/bin/eventhandler_linux.cc
index 7cd9e5140b743c4cafaddf7619ebf155a2f13031..8cda7927c3c5a23a30cd2369da99653200b02ccc 100644
--- a/runtime/bin/eventhandler_linux.cc
+++ b/runtime/bin/eventhandler_linux.cc
@@ -133,6 +133,7 @@ EventHandlerImplementation::EventHandlerImplementation()
EventHandlerImplementation::~EventHandlerImplementation() {
+ TEMP_FAILURE_RETRY(close(epoll_fd_));
TEMP_FAILURE_RETRY(close(interrupt_fds_[0]));
TEMP_FAILURE_RETRY(close(interrupt_fds_[1]));
}
@@ -375,12 +376,12 @@ void EventHandlerImplementation::HandleTimeout() {
void EventHandlerImplementation::Poll(uword args) {
static const intptr_t kMaxEvents = 16;
struct epoll_event events[kMaxEvents];
- EventHandlerImplementation* handler =
- reinterpret_cast<EventHandlerImplementation*>(args);
- ASSERT(handler != NULL);
- while (!handler->shutdown_) {
- intptr_t millis = handler->GetTimeout();
- intptr_t result = TEMP_FAILURE_RETRY(epoll_wait(handler->epoll_fd_,
+ 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();
+ intptr_t result = TEMP_FAILURE_RETRY(epoll_wait(handler_impl->epoll_fd_,
events,
kMaxEvents,
millis));
@@ -390,16 +391,17 @@ void EventHandlerImplementation::Poll(uword args) {
perror("Poll failed");
}
} 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::Poll,
- 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_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698