| Index: runtime/vm/port.cc
|
| diff --git a/runtime/vm/port.cc b/runtime/vm/port.cc
|
| index 037d55ac91b4ef54a90ddc2e3f4957699cb2c72a..0c9a627bb4ce27ede7e6a6fdaa8ea5be3d3468a2 100644
|
| --- a/runtime/vm/port.cc
|
| +++ b/runtime/vm/port.cc
|
| @@ -20,7 +20,7 @@ MessageHandler* PortMap::deleted_entry_ = reinterpret_cast<MessageHandler*>(1);
|
| intptr_t PortMap::capacity_ = 0;
|
| intptr_t PortMap::used_ = 0;
|
| intptr_t PortMap::deleted_ = 0;
|
| -Random* PortMap::prng_ = NULL;
|
| +Dart_Port PortMap::next_port_ = 7111;
|
|
|
|
|
| intptr_t PortMap::FindPort(Dart_Port port) {
|
| @@ -63,11 +63,13 @@ void PortMap::Rehash(intptr_t new_capacity) {
|
|
|
|
|
| Dart_Port PortMap::AllocatePort() {
|
| - Dart_Port result = prng_->NextUInt32() & kSmiMax;
|
| + Dart_Port result = next_port_;
|
|
|
| - while ((result == 0) && (FindPort(result) >= 0)) {
|
| - result = prng_->NextUInt32() & kSmiMax;
|
| - }
|
| + do {
|
| + // TODO(iposva): Use an approved hashing function to have less predictable
|
| + // port ids, or make them not accessible from Dart code or both.
|
| + next_port_++;
|
| + } while (FindPort(next_port_) >= 0);
|
|
|
| ASSERT(result != 0);
|
| return result;
|
| @@ -256,7 +258,6 @@ Isolate* PortMap::GetIsolate(Dart_Port id) {
|
|
|
| void PortMap::InitOnce() {
|
| mutex_ = new Mutex();
|
| - prng_ = new Random();
|
|
|
| static const intptr_t kInitialCapacity = 8;
|
| // TODO(iposva): Verify whether we want to keep exponentially growing.
|
|
|