From 58e923de6ef89f252f350d0d89f7b13798b517bd Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 13 Nov 2011 16:36:47 -0800 Subject: rt: Perform task notification before killing the parent task --- src/rt/rust_task.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index e5d43e7b308..b2158945182 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -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++ -- cgit 1.4.1-3-g733a5