[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 2/3] kernel2: rpc_destroy_task_backlinks von kernel1 portiert
+ kernel2: Damit beim Rueckkehr von einem RPC sicher auf den
Aufrufer-Task zugegriffen werden kann, muss ein beendeter Task aus
allen RPC-Backlinks gestrichen werden.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/kernel2/include/tasks.h | 2 ++
src/kernel2/src/syscalls/rpc.c | 17 ++++++++---------
src/kernel2/src/tasks/pm.c | 2 ++
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/kernel2/include/tasks.h b/src/kernel2/include/tasks.h
index 55e6614..1d3b6de 100644
--- a/src/kernel2/include/tasks.h
+++ b/src/kernel2/include/tasks.h
@@ -153,6 +153,8 @@ bool pm_unblock_rpc(pm_process_t* task, pid_t blocked_by);
void pm_register_on_destroy(pm_process_t* process,
pm_process_destroy_handler handler, void* prv);
+/// Entfernt den gegebenen Task aus allen RPC-Backlinks
+void rpc_destroy_task_backlinks(pm_process_t* destroyed_process);
/**
* Threadverwaltung
diff --git a/src/kernel2/src/syscalls/rpc.c b/src/kernel2/src/syscalls/rpc.c
index a8ec30b..e6ffd1a 100644
--- a/src/kernel2/src/syscalls/rpc.c
+++ b/src/kernel2/src/syscalls/rpc.c
@@ -400,7 +400,6 @@ void syscall_fastrpc_ret(void)
free(rpc);
}
-#if 0
/**
* Entfernt den gegebenen Task aus allen RPC-Backlinks.
*
@@ -408,22 +407,22 @@ void syscall_fastrpc_ret(void)
* wird, bevor der RPC fertig ist. Ansonsten zeigt rpc->caller ins Leere,
* was in return_from_rpc() zur Katastrophe führt.
*/
-void rpc_destroy_task_backlinks(struct task* destroyed_task)
+void rpc_destroy_task_backlinks(pm_process_t* destroyed_process)
{
- struct task* task;
- for (task = first_task; task != NULL; task = task->next_task) {
- int i;
+ pm_process_t* proc;
+ int i;
+
+ for (i = 0; (proc = list_get_element_at(process_list, i)); i++) {
+ int j;
rpc_t* rpc;
- for (i = 0; (rpc = list_get_element_at(task->rpcs, i)); i++) {
- if (rpc->caller == destroyed_task) {
+ for (j = 0; (rpc = list_get_element_at(proc->rpcs, j)); j++) {
+ if (rpc->caller->process == destroyed_process) {
rpc->caller = NULL;
}
}
}
}
-#endif
-
void syscall_add_interrupt_handler(uint32_t intr)
{
im_add_handler(intr, current_process);
diff --git a/src/kernel2/src/tasks/pm.c b/src/kernel2/src/tasks/pm.c
index dde8f33..4d70e4f 100644
--- a/src/kernel2/src/tasks/pm.c
+++ b/src/kernel2/src/tasks/pm.c
@@ -178,6 +178,8 @@ void pm_destroy(pm_process_t* process)
// RPC-Strukturen freigeben
// TODO Die einzelnen Listenglieder freigeben
list_destroy(process->rpcs);
+ process->rpcs = NULL;
+ rpc_destroy_task_backlinks(process);
// TODO Alle SHMs freigeben
--
1.6.0.2