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

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: 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
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..b7c5ac1949f79e4cebcac441e1bb466da06a08e7 100644
--- a/dart/runtime/bin/eventhandler_linux.h
+++ b/dart/runtime/bin/eventhandler_linux.h
@@ -187,21 +187,30 @@ 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.
Søren Gjesse 2014/10/22 07:23:51 Add "do nothing" to the comment to make it obvious
kustermann 2014/10/23 21:59:23 Done.
+ //
+ // 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.
+ // 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();
}

Powered by Google App Engine
This is Rietveld 408576698