mirror of
https://github.com/rust-lang/rust
synced 2024-09-15 22:50:55 +00:00
rt: Perform task notification before killing the parent task
This commit is contained in:
parent
138d9ca5d5
commit
58e923de6e
|
@ -81,7 +81,7 @@ fn chan_id_send<uniq T>(t: *sys::type_desc,
|
|||
while rustrt::rust_port_size(po) > 0u {
|
||||
// FIXME: For some reason if we don't assign to something here
|
||||
// we end up with invalid reads in the drop glue.
|
||||
let t = rusti::recv::<T>(po);
|
||||
let _t = rusti::recv::<T>(po);
|
||||
}
|
||||
rustrt::del_port(po);
|
||||
}
|
||||
|
|
|
@ -126,24 +126,6 @@ rust_task::~rust_task()
|
|||
DLOG(sched, task, "~rust_task %s @0x%" PRIxPTR ", refcnt=%d",
|
||||
name, (uintptr_t)this, ref_count);
|
||||
|
||||
if(user.notify_enabled) {
|
||||
rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
|
||||
if (target_task) {
|
||||
rust_port *target_port =
|
||||
target_task->get_port_by_id(user.notify_chan.port);
|
||||
if(target_port) {
|
||||
task_notification msg;
|
||||
msg.id = user.id;
|
||||
msg.result = failed ? tr_failure : tr_success;
|
||||
|
||||
target_port->send(&msg);
|
||||
scoped_lock with(target_task->lock);
|
||||
target_port->deref();
|
||||
}
|
||||
target_task->deref();
|
||||
}
|
||||
}
|
||||
|
||||
if (supervisor) {
|
||||
supervisor->deref();
|
||||
}
|
||||
|
@ -203,6 +185,8 @@ void task_start_wrapper(spawn_args *a)
|
|||
failed = true;
|
||||
}
|
||||
|
||||
task->notify(!failed);
|
||||
|
||||
if (failed) {
|
||||
#ifndef __WIN32__
|
||||
task->conclude_failure();
|
||||
|
@ -605,6 +589,28 @@ rust_task::claim_alloc(void *alloc, const type_desc *tydesc) {
|
|||
lock.unlock();
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::notify(bool success) {
|
||||
// FIXME (1078) Do this in rust code
|
||||
if(user.notify_enabled) {
|
||||
rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
|
||||
if (target_task) {
|
||||
rust_port *target_port =
|
||||
target_task->get_port_by_id(user.notify_chan.port);
|
||||
if(target_port) {
|
||||
task_notification msg;
|
||||
msg.id = user.id;
|
||||
msg.result = !success ? tr_failure : tr_success;
|
||||
|
||||
target_port->send(&msg);
|
||||
scoped_lock with(target_task->lock);
|
||||
target_port->deref();
|
||||
}
|
||||
target_task->deref();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
|
|
|
@ -213,6 +213,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
|||
// ground. We should never be migrating shared boxes between tasks.
|
||||
const type_desc *release_alloc(void *alloc);
|
||||
void claim_alloc(void *alloc, const type_desc *tydesc);
|
||||
|
||||
void notify(bool success);
|
||||
};
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue