mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
sched/mqueue: Enable receiving messages on an interrupt handler
The internal implementation of `file_mq_receive` did not allow receiving a message from an interrupt handler. Although it is not possible to wait for a message in an interrupt context, it is perfectly possible to retrieve already-existing messages from the message queue. This commit modifies file_mq_timedreceive_internal to enable checking the message list and, if no messages exist, it returns immediately. This enables receiving any existing messages in an interrupt context. Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
This commit is contained in:
committed by
Matteo Golin
parent
cbe13affa1
commit
9cf7d80bab
@@ -145,8 +145,6 @@ ssize_t file_mq_timedreceive_internal(FAR struct file *mq, FAR char *msg,
|
||||
irqstate_t flags;
|
||||
ssize_t ret = 0;
|
||||
|
||||
DEBUGASSERT(up_interrupt_context() == false);
|
||||
|
||||
/* Verify the input parameters */
|
||||
|
||||
if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
|
||||
@@ -190,6 +188,14 @@ ssize_t file_mq_timedreceive_internal(FAR struct file *mq, FAR char *msg,
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/* If we are in interrupt context, return EAGAIN instead of blocking */
|
||||
|
||||
if (up_interrupt_context())
|
||||
{
|
||||
leave_critical_section(flags);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/* Wait & get the message from the message queue */
|
||||
|
||||
ret = nxmq_wait_receive(msgq, &mqmsg, abstime, ticks);
|
||||
|
||||
Reference in New Issue
Block a user