Skip to content

Commit 692d3e5

Browse files
committed
---
yaml --- r: 14329 b: refs/heads/try c: 96af6f0 h: refs/heads/master i: 14327: 3b7ae02 v: v3
1 parent 09af02c commit 692d3e5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 601f7144d842dca97440d34774b5ae4c839a43c4
5+
refs/heads/try: 96af6f05a1881ba669637d3982a0d3315722c0d2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_port_selector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ rust_port_selector::select(rust_task *task, rust_port **dptr,
2626
// block the task before any of them can try to send another
2727
// message.
2828

29+
// Start looking for ports from a different index each time.
30+
size_t j = isaac_rand(&task->thread->rctx);
2931
for (size_t i = 0; i < n_ports; i++) {
30-
rust_port *port = ports[i];
32+
size_t k = (i + j) % n_ports;
33+
rust_port *port = ports[k];
3134
I(task->thread, port != NULL);
3235

3336
port->lock.lock();
@@ -50,7 +53,8 @@ rust_port_selector::select(rust_task *task, rust_port **dptr,
5053
}
5154

5255
for (size_t i = 0; i < locks_taken; i++) {
53-
rust_port *port = ports[i];
56+
size_t k = (i + j) % n_ports;
57+
rust_port *port = ports[k];
5458
port->lock.unlock();
5559
}
5660
}

0 commit comments

Comments
 (0)