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

Unified Diff: runtime/bin/eventhandler.cc

Issue 19546002: Clear EventHandler on Stop, to avoid future usages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler.cc
diff --git a/runtime/bin/eventhandler.cc b/runtime/bin/eventhandler.cc
index d4d8a285bc40ffa5e74845fbe827fa7327ea61b3..8365705d96d107ffbf9524c4ef0de872b6382d6a 100644
--- a/runtime/bin/eventhandler.cc
+++ b/runtime/bin/eventhandler.cc
@@ -66,13 +66,17 @@ void TimeoutQueue::UpdateTimeout(Dart_Port port, int64_t timeout) {
* Returns the reference of the EventHandler stored in the native field.
*/
static EventHandler* GetEventHandler(Dart_Handle handle) {
- ASSERT(event_handler != NULL);
+ MutexLocker locker(mutex_);
Florian Schneider 2013/07/17 08:38:09 Why is a mutex needed here?
Anders Johnsen 2013/07/17 08:59:49 Done.
return event_handler;
}
+
void EventHandler::Stop() {
+ MutexLocker locker(mutex_);
if (event_handler == NULL) return;
- event_handler->Shutdown();
+ EventHandler* e = event_handler;
+ event_handler = NULL;
+ e->Shutdown();
}
@@ -97,18 +101,21 @@ void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
Dart_EnterScope();
Dart_Handle handle = Dart_GetNativeArgument(args, 0);
EventHandler* event_handler = GetEventHandler(handle);
Florian Schneider 2013/07/17 08:38:09 Maybe not such a good idea to have a local variabl
Anders Johnsen 2013/07/17 08:59:49 Done.
- Dart_Handle sender = Dart_GetNativeArgument(args, 1);
- intptr_t id = kInvalidId;
- if (Dart_IsNull(sender)) {
- id = kTimerId;
- } else {
- Socket::GetSocketIdNativeField(sender, &id);
+ // Only send if the event handler is active.
+ if (event_handler) {
kustermann 2013/07/17 08:49:46 Please add a comment when event_handler is NULL an
Anders Johnsen 2013/07/17 08:59:49 Done.
+ Dart_Handle sender = Dart_GetNativeArgument(args, 1);
+ intptr_t id = kInvalidId;
+ if (Dart_IsNull(sender)) {
+ id = kTimerId;
+ } else {
+ Socket::GetSocketIdNativeField(sender, &id);
+ }
+ handle = Dart_GetNativeArgument(args, 2);
+ Dart_Port dart_port =
+ DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName);
+ int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
+ event_handler->SendData(id, dart_port, data);
}
- handle = Dart_GetNativeArgument(args, 2);
- Dart_Port dart_port =
- DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName);
- int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
- event_handler->SendData(id, dart_port, data);
Dart_ExitScope();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698