Module: xenomai-2.5 Branch: master Commit: f327a19d9bbdc6ba3cbf2a79c87ace8d1ef80e25 URL: http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=f327a19d9bbdc6ba3cbf2a79c87ace8d1ef80e25
Author: Philippe Gerum <r...@xenomai.org> Date: Thu Jun 9 15:05:56 2011 +0200 native: care for spurious wakeups in rt_task_receive() --- ksrc/skins/native/task.c | 35 +++++++++++++++++++++-------------- 1 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ksrc/skins/native/task.c b/ksrc/skins/native/task.c index b822fd0..b0e99a7 100644 --- a/ksrc/skins/native/task.c +++ b/ksrc/skins/native/task.c @@ -1988,21 +1988,28 @@ int rt_task_receive(RT_TASK_MCB *mcb_r, RTIME timeout) } /* - * Wait on our receive slot for some client to enqueue itself - * in our send queue. + * We loop to care for spurious wakeups, in case the + * client times out before we unblock. */ - info = xnsynch_sleep_on(&server->mrecv, timeout, XN_RELATIVE); - /* - * XNRMID cannot happen, since well, the current task would be the - * deleted object, so... - */ - if (info & XNTIMEO) { - err = -ETIMEDOUT; /* Timeout. */ - goto unlock_and_exit; - } else if (info & XNBREAK) { - err = -EINTR; /* Unblocked. */ - goto unlock_and_exit; - } + do { + /* + * Wait on our receive slot for some client to enqueue + * itself in our send queue. + */ + info = xnsynch_sleep_on(&server->mrecv, timeout, XN_RELATIVE); + /* + * XNRMID cannot happen, since well, the current task + * would be the deleted object, so... + */ + if (info & XNTIMEO) { + err = -ETIMEDOUT; /* Timeout. */ + goto unlock_and_exit; + } + if (info & XNBREAK) { + err = -EINTR; /* Unblocked. */ + goto unlock_and_exit; + } + } while (!xnsynch_pended_p(&server->mrecv)); holder = getheadpq(xnsynch_wait_queue(&server->msendq)); /* There must be a valid holder since we waited for it. */ _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git