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

Unified Diff: dart/runtime/bin/eventhandler_linux.h

Issue 665823007: Several bugfixes in dart:io's handing of sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added two spaces as requested Created 6 years, 2 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 | « dart/runtime/bin/eventhandler_android.cc ('k') | dart/runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/bin/eventhandler_linux.h
diff --git a/dart/runtime/bin/eventhandler_linux.h b/dart/runtime/bin/eventhandler_linux.h
index 1a8d968a3b218785e24eb886842756fbcc8120ae..0db4f3faa5bc35789417386187be6fd43657ecfc 100644
--- a/dart/runtime/bin/eventhandler_linux.h
+++ b/dart/runtime/bin/eventhandler_linux.h
@@ -187,21 +187,32 @@ class ListeningSocketData : public SocketData {
virtual bool RemovePort(Dart_Port port) {
HashMap::Entry* entry = tokens_map_.Lookup(
GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false);
- ASSERT(entry != NULL);
- intptr_t tokens = reinterpret_cast<intptr_t>(entry->value);
- if (tokens == 0) {
- while (idle_ports_.head() != port) {
- idle_ports_.Rotate();
+ if (entry != NULL) {
+ intptr_t tokens = reinterpret_cast<intptr_t>(entry->value);
+ if (tokens == 0) {
+ while (idle_ports_.head() != port) {
+ idle_ports_.Rotate();
+ }
+ idle_ports_.RemoveHead();
+ } else {
+ while (live_ports_.head() != port) {
+ live_ports_.Rotate();
+ }
+ live_ports_.RemoveHead();
}
- idle_ports_.RemoveHead();
+ tokens_map_.Remove(
+ GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port));
} else {
- while (live_ports_.head() != port) {
- live_ports_.Rotate();
- }
- live_ports_.RemoveHead();
+ // NOTE: This is a listening socket which has been immediately closed.
+ //
+ // If a listening socket is not listened on, the event handler does not
+ // know about it beforehand. So the first time the event handler knows
+ // about it, is when it is supposed to be closed. We therefore do nothing
+ // here.
+ //
+ // But whether to close it, depends on whether other isolates have it open
+ // as well or not.
}
- tokens_map_.Remove(
- GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port));
return !live_ports_.HasHead();
}
« no previous file with comments | « dart/runtime/bin/eventhandler_android.cc ('k') | dart/runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698