From d8a5ee1ec875b9cec83be95d727ad4849feebc13 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 8 Jul 2014 17:49:16 +0200 Subject: [PATCH] core/msg: set m->sender_pid before it is used fixes `msg_send_to_self` condition --- core/msg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/msg.c b/core/msg.c index 82d164e336..3492f24a1c 100644 --- a/core/msg.c +++ b/core/msg.c @@ -58,6 +58,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) return msg_send_int(m, target_pid); } + m->sender_pid = sched_active_pid; if (m->sender_pid == target_pid) { return msg_send_to_self(m); } @@ -66,8 +67,6 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) tcb_t *target = (tcb_t*) sched_threads[target_pid]; - m->sender_pid = sched_active_pid; - if (target == NULL) { DEBUG("msg_send(): target thread does not exist\n"); eINT();