Chromium Code Reviews| 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(); |
| } |