2007-03-29 15:25:18 +02:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* sched/mqueue/mq_timedreceive.c
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
2020-03-10 16:26:30 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
2020-03-10 16:26:30 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
2020-03-10 16:26:30 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2009-12-14 19:39:29 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2007-03-29 15:25:18 +02:00
|
|
|
#include <sys/types.h>
|
2009-12-14 19:39:29 +01:00
|
|
|
#include <stdint.h>
|
2009-12-14 22:15:18 +01:00
|
|
|
#include <stdbool.h>
|
2007-03-29 15:25:18 +02:00
|
|
|
#include <unistd.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2007-03-29 15:25:18 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <mqueue.h>
|
|
|
|
#include <debug.h>
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
#include <nuttx/irq.h>
|
2007-03-29 15:25:18 +02:00
|
|
|
#include <nuttx/arch.h>
|
2014-08-21 19:16:55 +02:00
|
|
|
#include <nuttx/wdog.h>
|
2017-10-10 17:57:40 +02:00
|
|
|
#include <nuttx/mqueue.h>
|
2016-12-10 16:08:26 +01:00
|
|
|
#include <nuttx/cancelpt.h>
|
2009-12-14 19:39:29 +01:00
|
|
|
|
2014-08-09 01:53:55 +02:00
|
|
|
#include "sched/sched.h"
|
2014-08-08 22:43:02 +02:00
|
|
|
#include "clock/clock.h"
|
2014-08-08 20:31:23 +02:00
|
|
|
#include "mqueue/mqueue.h"
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-10-09 17:06:46 +02:00
|
|
|
* Name: nxmq_rcvtimeout
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called if the timeout elapses before the message queue
|
|
|
|
* becomes non-empty.
|
|
|
|
*
|
2017-10-10 17:57:40 +02:00
|
|
|
* Input Parameters:
|
2007-03-29 15:25:18 +02:00
|
|
|
* pid - the task ID of the task to wakeup
|
|
|
|
*
|
2017-10-10 17:57:40 +02:00
|
|
|
* Returned Value:
|
2007-03-29 15:25:18 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-08-09 20:29:35 +02:00
|
|
|
static void nxmq_rcvtimeout(wdparm_t pid)
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2013-02-04 19:46:28 +01:00
|
|
|
FAR struct tcb_s *wtcb;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2007-03-29 15:25:18 +02:00
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* Disable interrupts. This is necessary because an interrupt handler may
|
|
|
|
* attempt to send a message while we are doing this.
|
2007-03-29 15:25:18 +02:00
|
|
|
*/
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2007-03-29 15:25:18 +02:00
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* Get the TCB associated with this pid. It is possible that task may no
|
|
|
|
* longer be active when this watchdog goes off.
|
2007-03-29 15:25:18 +02:00
|
|
|
*/
|
|
|
|
|
2020-08-09 20:29:35 +02:00
|
|
|
wtcb = nxsched_get_tcb(pid);
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* It is also possible that an interrupt/context switch beat us to the
|
|
|
|
* punch and already changed the task's state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (wtcb && wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
|
|
|
|
{
|
2011-09-21 15:28:16 +02:00
|
|
|
/* Restart with task with a timeout error */
|
2007-03-29 15:25:18 +02:00
|
|
|
|
2017-10-09 17:06:46 +02:00
|
|
|
nxmq_wait_irq(wtcb, ETIMEDOUT);
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 15:28:16 +02:00
|
|
|
/* Interrupts may now be re-enabled. */
|
2007-03-29 15:25:18 +02:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2024-05-10 11:21:40 +02:00
|
|
|
* Name: file_mq_timedreceive_internal
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2024-05-10 11:21:40 +02:00
|
|
|
* This is an internal function of file_mq_timedreceive()/
|
|
|
|
* file_mq_tickreceive(), please refer to the detailed description for
|
|
|
|
* more information.
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
2017-10-10 17:57:40 +02:00
|
|
|
* Input Parameters:
|
2020-12-24 13:53:17 +01:00
|
|
|
* mq - Message Queue Descriptor
|
2017-10-10 17:57:40 +02:00
|
|
|
* msg - Buffer to receive the message
|
|
|
|
* msglen - Size of the buffer in bytes
|
|
|
|
* prio - If not NULL, the location to store message priority.
|
2007-03-29 15:25:18 +02:00
|
|
|
* abstime - the absolute time to wait until a timeout is declared.
|
2024-05-10 11:21:40 +02:00
|
|
|
* ticks - Ticks to wait from the start time until the semaphore is
|
|
|
|
* posted.
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
2017-10-10 17:57:40 +02:00
|
|
|
* Returned Value:
|
|
|
|
* This is an internal OS interface and should not be used by applications.
|
|
|
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
|
|
|
* returned on success. A negated errno value is returned on failure.
|
|
|
|
* (see mq_timedreceive() for the list list valid return values).
|
2007-03-29 15:25:18 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-05-10 11:21:40 +02:00
|
|
|
static ssize_t
|
|
|
|
file_mq_timedreceive_internal(FAR struct file *mq, FAR char *msg,
|
|
|
|
size_t msglen, FAR unsigned int *prio,
|
|
|
|
FAR const struct timespec *abstime,
|
|
|
|
sclock_t ticks)
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2016-02-07 00:44:41 +01:00
|
|
|
FAR struct tcb_s *rtcb = this_task();
|
2020-12-22 15:02:48 +01:00
|
|
|
FAR struct mqueue_inode_s *msgq;
|
2014-09-29 21:35:32 +02:00
|
|
|
FAR struct mqueue_msg_s *mqmsg;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2017-10-10 17:57:40 +02:00
|
|
|
int ret;
|
2007-03-29 15:25:18 +02:00
|
|
|
|
2020-08-04 12:31:31 +02:00
|
|
|
DEBUGASSERT(up_interrupt_context() == false);
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* Verify the input parameters and, in case of an error, set
|
|
|
|
* errno appropriately.
|
|
|
|
*/
|
|
|
|
|
2022-06-09 07:37:11 +02:00
|
|
|
ret = nxmq_verify_receive(mq, msg, msglen);
|
2017-10-10 17:57:40 +02:00
|
|
|
if (ret < 0)
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2017-10-10 17:57:40 +02:00
|
|
|
return ret;
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
2022-06-09 07:37:11 +02:00
|
|
|
msgq = mq->f_inode->i_private;
|
|
|
|
|
2017-10-09 17:06:46 +02:00
|
|
|
/* Furthermore, nxmq_wait_receive() expects to have interrupts disabled
|
2007-03-29 15:25:18 +02:00
|
|
|
* because messages can be sent from interrupt level.
|
|
|
|
*/
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* Check if the message queue is empty. If it is NOT empty, then we
|
|
|
|
* will not need to start timer.
|
|
|
|
*/
|
|
|
|
|
2022-06-08 16:42:01 +02:00
|
|
|
if (list_is_empty(&msgq->msglist))
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2024-05-10 11:21:40 +02:00
|
|
|
if (abstime != NULL)
|
|
|
|
{
|
|
|
|
if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Convert the timespec to clock ticks.
|
|
|
|
* We must have interrupts disabled here so that
|
|
|
|
* this time stays valid until the wait begins.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = clock_abstime2ticks(CLOCK_REALTIME, abstime, &ticks);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle any time-related errors */
|
|
|
|
|
|
|
|
if (ret != OK)
|
|
|
|
{
|
|
|
|
goto errout_in_critical_section;
|
|
|
|
}
|
|
|
|
}
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* If the time has already expired and the message queue is empty,
|
|
|
|
* return immediately.
|
|
|
|
*/
|
|
|
|
|
2024-05-10 11:21:40 +02:00
|
|
|
if (ticks <= 0)
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2024-05-10 11:21:40 +02:00
|
|
|
ret = -ETIMEDOUT;
|
2022-06-08 14:39:03 +02:00
|
|
|
goto errout_in_critical_section;
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Start the watchdog */
|
|
|
|
|
2023-02-01 11:05:58 +01:00
|
|
|
wd_start(&rtcb->waitdog, ticks,
|
|
|
|
nxmq_rcvtimeout, nxsched_gettid());
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the message from the message queue */
|
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
ret = nxmq_wait_receive(msgq, mq->f_oflags, &mqmsg);
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* Stop the watchdog timer (this is not harmful in the case where
|
|
|
|
* it was never started)
|
|
|
|
*/
|
|
|
|
|
2020-08-04 12:31:31 +02:00
|
|
|
wd_cancel(&rtcb->waitdog);
|
2007-03-29 15:25:18 +02:00
|
|
|
|
|
|
|
/* Check if we got a message from the message queue. We might
|
|
|
|
* not have a message if:
|
|
|
|
*
|
|
|
|
* - The message queue is empty and O_NONBLOCK is set in the mqdes
|
|
|
|
* - The wait was interrupted by a signal
|
|
|
|
* - The watchdog timeout expired
|
|
|
|
*/
|
|
|
|
|
2022-06-08 14:39:03 +02:00
|
|
|
if (ret == OK)
|
2007-03-29 15:25:18 +02:00
|
|
|
{
|
2017-10-10 17:57:40 +02:00
|
|
|
DEBUGASSERT(mqmsg != NULL);
|
2020-12-22 15:02:48 +01:00
|
|
|
ret = nxmq_do_receive(msgq, mqmsg, msg, prio);
|
2007-03-29 15:25:18 +02:00
|
|
|
}
|
|
|
|
|
2022-06-08 14:39:03 +02:00
|
|
|
/* We can now restore interrupts */
|
|
|
|
|
|
|
|
errout_in_critical_section:
|
|
|
|
leave_critical_section(flags);
|
|
|
|
|
2017-10-10 17:57:40 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-05-10 11:21:40 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: file_mq_timedreceive
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function receives the oldest of the highest priority messages from
|
|
|
|
* the message queue specified by "mq." If the message queue is empty
|
|
|
|
* and O_NONBLOCK was not set, file_mq_timedreceive() will block until a
|
|
|
|
* message is added to the message queue (or until a timeout occurs).
|
|
|
|
*
|
|
|
|
* file_mq_timedreceive() is an internal OS interface. It is functionally
|
|
|
|
* equivalent to mq_timedreceive() except that:
|
|
|
|
*
|
|
|
|
* - It is not a cancellation point, and
|
|
|
|
* - It does not modify the errno value.
|
|
|
|
*
|
|
|
|
* See comments with mq_timedreceive() for a more complete description of
|
|
|
|
* the behavior of this function
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mq - Message Queue Descriptor
|
|
|
|
* msg - Buffer to receive the message
|
|
|
|
* msglen - Size of the buffer in bytes
|
|
|
|
* prio - If not NULL, the location to store message priority.
|
|
|
|
* abstime - the absolute time to wait until a timeout is declared.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This is an internal OS interface and should not be used by applications.
|
|
|
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
|
|
|
* returned on success. A negated errno value is returned on failure.
|
|
|
|
* (see mq_timedreceive() for the list list valid return values).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t file_mq_timedreceive(FAR struct file *mq, FAR char *msg,
|
|
|
|
size_t msglen, FAR unsigned int *prio,
|
|
|
|
FAR const struct timespec *abstime)
|
|
|
|
{
|
|
|
|
return file_mq_timedreceive_internal(mq, msg, msglen, prio, abstime, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: file_mq_tickreceive
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function receives the oldest of the highest priority messages from
|
|
|
|
* the message queue specified by "mq." If the message queue is empty
|
|
|
|
* and O_NONBLOCK was not set, file_mq_tickreceive() will block until a
|
|
|
|
* message is added to the message queue (or until a timeout occurs).
|
|
|
|
*
|
|
|
|
* file_mq_tickreceive() is an internal OS interface. It is functionally
|
|
|
|
* equivalent to mq_timedreceive() except that:
|
|
|
|
*
|
|
|
|
* - It is not a cancellation point, and
|
|
|
|
* - It does not modify the errno value.
|
|
|
|
*
|
|
|
|
* See comments with mq_timedreceive() for a more complete description of
|
|
|
|
* the behavior of this function
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mq - Message Queue Descriptor
|
|
|
|
* msg - Buffer to receive the message
|
|
|
|
* msglen - Size of the buffer in bytes
|
|
|
|
* prio - If not NULL, the location to store message priority.
|
|
|
|
* ticks - Ticks to wait from the start time until the semaphore is
|
|
|
|
* posted.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This is an internal OS interface and should not be used by applications.
|
|
|
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
|
|
|
* returned on success. A negated errno value is returned on failure.
|
|
|
|
* (see mq_timedreceive() for the list list valid return values).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t file_mq_tickreceive(FAR struct file *mq, FAR char *msg,
|
|
|
|
size_t msglen, FAR unsigned int *prio,
|
|
|
|
sclock_t ticks)
|
|
|
|
{
|
|
|
|
return file_mq_timedreceive_internal(mq, msg, msglen, prio, NULL, ticks);
|
|
|
|
}
|
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmq_timedreceive
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function receives the oldest of the highest priority messages from
|
|
|
|
* the message queue specified by "mqdes." If the message queue is empty
|
|
|
|
* and O_NONBLOCK was not set, nxmq_timedreceive() will block until a
|
|
|
|
* message is added to the message queue (or until a timeout occurs).
|
|
|
|
*
|
|
|
|
* nxmq_timedreceive() is an internal OS interface. It is functionally
|
|
|
|
* equivalent to mq_timedreceive() except that:
|
|
|
|
*
|
|
|
|
* - It is not a cancellation point, and
|
|
|
|
* - It does not modify the errno value.
|
|
|
|
*
|
|
|
|
* See comments with mq_timedreceive() for a more complete description of
|
|
|
|
* the behavior of this function
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mqdes - Message Queue Descriptor
|
|
|
|
* msg - Buffer to receive the message
|
|
|
|
* msglen - Size of the buffer in bytes
|
|
|
|
* prio - If not NULL, the location to store message priority.
|
|
|
|
* abstime - the absolute time to wait until a timeout is declared.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This is an internal OS interface and should not be used by applications.
|
|
|
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
|
|
|
* returned on success. A negated errno value is returned on failure.
|
|
|
|
* (see mq_timedreceive() for the list list valid return values).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|
|
|
FAR unsigned int *prio,
|
|
|
|
FAR const struct timespec *abstime)
|
|
|
|
{
|
|
|
|
FAR struct file *filep;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = fs_getfilep(mqdes, &filep);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-05-10 11:21:40 +02:00
|
|
|
return file_mq_timedreceive_internal(filep, msg, msglen, prio, abstime, 0);
|
2020-12-24 13:53:17 +01:00
|
|
|
}
|
|
|
|
|
2017-10-10 17:57:40 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: mq_timedreceive
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function receives the oldest of the highest priority messages from
|
|
|
|
* the message queue specified by "mqdes." If the size of the buffer in
|
|
|
|
* bytes (msglen) is less than the "mq_msgsize" attribute of the message
|
|
|
|
* queue, mq_timedreceive will return an error. Otherwise, the selected
|
|
|
|
* message is removed from the queue and copied to "msg."
|
|
|
|
*
|
|
|
|
* If the message queue is empty and O_NONBLOCK was not set,
|
|
|
|
* mq_timedreceive() will block until a message is added to the message
|
|
|
|
* queue (or until a timeout occurs). If more than one task is waiting
|
|
|
|
* to receive a message, only the task with the highest priority that has
|
|
|
|
* waited the longest will be unblocked.
|
|
|
|
*
|
|
|
|
* mq_timedreceive() behaves just like mq_receive(), except that if the
|
|
|
|
* queue is empty and the O_NONBLOCK flag is not enabled for the message
|
|
|
|
* queue description, then abstime points to a structure which specifies a
|
|
|
|
* ceiling on the time for which the call will block. This ceiling is an
|
|
|
|
* absolute timeout in seconds and nanoseconds since the Epoch (midnight
|
|
|
|
* on the morning of 1 January 1970).
|
|
|
|
*
|
|
|
|
* If no message is available, and the timeout has already expired by the
|
|
|
|
* time of the call, mq_timedreceive() returns immediately.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mqdes - Message Queue Descriptor
|
|
|
|
* msg - Buffer to receive the message
|
|
|
|
* msglen - Size of the buffer in bytes
|
|
|
|
* prio - If not NULL, the location to store message priority.
|
|
|
|
* abstime - the absolute time to wait until a timeout is declared.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2021-05-06 04:18:49 +02:00
|
|
|
* On success, the length of the selected message in bytes is returned.
|
2017-10-10 17:57:40 +02:00
|
|
|
* On failure, -1 (ERROR) is returned and the errno is set appropriately:
|
|
|
|
*
|
|
|
|
* EAGAIN The queue was empty, and the O_NONBLOCK flag was set
|
|
|
|
* for the message queue description referred to by 'mqdes'.
|
|
|
|
* EPERM Message queue opened not opened for reading.
|
|
|
|
* EMSGSIZE 'msglen' was less than the maxmsgsize attribute of the
|
|
|
|
* message queue.
|
|
|
|
* EINTR The call was interrupted by a signal handler.
|
|
|
|
* EINVAL Invalid 'msg' or 'mqdes' or 'abstime'
|
|
|
|
* ETIMEDOUT The call timed out before a message could be transferred.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
2019-02-16 02:18:55 +01:00
|
|
|
FAR unsigned int *prio,
|
|
|
|
FAR const struct timespec *abstime)
|
2017-10-10 17:57:40 +02:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* mq_timedreceive() is a cancellation point */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
enter_cancellation_point();
|
2017-10-10 17:57:40 +02:00
|
|
|
|
|
|
|
/* Let nxmq_timedreceive do all of the work */
|
|
|
|
|
|
|
|
ret = nxmq_timedreceive(mqdes, msg, msglen, prio, abstime);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
set_errno(-ret);
|
|
|
|
ret = ERROR;
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:50:34 +01:00
|
|
|
leave_cancellation_point();
|
2007-03-29 15:25:18 +02:00
|
|
|
return ret;
|
|
|
|
}
|