Skip to content

Commit 79903ef

Browse files
committed
---
yaml --- r: 6255 b: refs/heads/master c: 3d9023f h: refs/heads/master i: 6253: a287734 6251: cdeac4d 6247: b3e7326 6239: 6658079 v: v3
1 parent 9c4ba84 commit 79903ef

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 07771ec25bc394a4a053252a2b5441f3160a0568
2+
refs/heads/master: 3d9023fa4ddc8dbb5d9be0e4e4ef5c284c6b077a

trunk/src/rt/rust_builtin.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ extern "C" CDECL void
471471
del_port(rust_port *port) {
472472
rust_task *task = rust_scheduler::get_task();
473473
LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
474+
scoped_lock with(task->lock);
474475
port->deref();
475476
}
476477

@@ -487,11 +488,12 @@ chan_id_send(type_desc *t, rust_task_id target_task_id,
487488
rust_task *target_task = task->kernel->get_task_by_id(target_task_id);
488489
if(target_task) {
489490
rust_port *port = target_task->get_port_by_id(target_port_id);
490-
target_task->deref();
491491
if(port) {
492492
port->send(sptr);
493+
scoped_lock with(target_task->lock);
493494
port->deref();
494495
}
496+
target_task->deref();
495497
}
496498
}
497499

trunk/src/rt/rust_task.cpp

+15-20
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,20 @@ rust_task::~rust_task()
127127
name, (uintptr_t)this, ref_count);
128128

129129
if(user.notify_enabled) {
130-
rust_port *target =
131-
get_port_by_chan_handle(&user.notify_chan);
132-
if(target) {
133-
task_notification msg;
134-
msg.id = user.id;
135-
msg.result = failed ? tr_failure : tr_success;
136-
137-
target->send(&msg);
138-
target->deref();
130+
rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
131+
if (target_task) {
132+
rust_port *target_port =
133+
target_task->get_port_by_id(user.notify_chan.port);
134+
if(target_port) {
135+
task_notification msg;
136+
msg.id = user.id;
137+
msg.result = failed ? tr_failure : tr_success;
138+
139+
target_port->send(&msg);
140+
scoped_lock with(target_task->lock);
141+
target_port->deref();
142+
}
143+
target_task->deref();
139144
}
140145
}
141146

@@ -553,8 +558,7 @@ rust_port_id rust_task::register_port(rust_port *port) {
553558
}
554559

555560
void rust_task::release_port(rust_port_id id) {
556-
I(sched, !lock.lock_held_by_current_thread());
557-
scoped_lock with(lock);
561+
I(sched, lock.lock_held_by_current_thread());
558562
port_table.remove(id);
559563
}
560564

@@ -569,15 +573,6 @@ rust_port *rust_task::get_port_by_id(rust_port_id id) {
569573
return port;
570574
}
571575

572-
rust_port *rust_task::get_port_by_chan_handle(chan_handle *handle) {
573-
rust_task *target_task = kernel->get_task_by_id(handle->task);
574-
if(target_task) {
575-
rust_port *port = target_task->get_port_by_id(handle->port);
576-
target_task->deref();
577-
return port;
578-
}
579-
return NULL;
580-
}
581576

582577
// Temporary routine to allow boxes on one task's shared heap to be reparented
583578
// to another.

trunk/src/rt/rust_task.h

-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
209209
// not at all safe.
210210
intptr_t get_ref_count() const { return ref_count; }
211211

212-
rust_port *get_port_by_chan_handle(chan_handle *handle);
213-
214212
// FIXME: These functions only exist to get the tasking system off the
215213
// ground. We should never be migrating shared boxes between tasks.
216214
const type_desc *release_alloc(void *alloc);
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
// xfail-test
21
// xfail-win32
32
use std;
43
import std::comm;
54
import std::task;
65

7-
fn start(c: comm::chan<int>, n: int) {
8-
let i: int = n;
6+
fn start(&&args: (comm::chan<int>, int)) {
7+
let (c, i) = args;
98

109
while i > 0 { comm::send(c, 0); i = i - 1; }
1110
}
@@ -16,6 +15,6 @@ fn main() {
1615
// is likely to terminate before the child completes, so from
1716
// the child's point of view the receiver may die. We should
1817
// drop messages on the floor in this case, and not crash!
19-
let child = task::spawn(bind start(comm::chan(p), 10));
18+
let child = task::spawn((comm::chan(p), 10), start);
2019
let c = comm::recv(p);
2120
}

0 commit comments

Comments
 (0)