mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:43:28 +08:00
Squashed commit of the following:
Change all calls to mq_send() and mq_timedsend() in the OS to calls to nxmq_send() and nxmq_timedsend(), making appropriate changes for differences in return values.
sched/mqueue: Add internal function nxmq_send() and nxmq_timedsend() that are equivalent to mq_send() and mq_timedsend() except that they do not create cancellation points and do to not modify the errno variable.
This commit is contained in:
+20
-10
@@ -55,11 +55,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mq_close_group
|
||||
* Name: nxmq_close_group
|
||||
*
|
||||
* Description:
|
||||
* This function is used to indicate that all threads in the group are
|
||||
* finished with the specified message queue mqdes. The mq_close_group()
|
||||
* finished with the specified message queue mqdes. The nxmq_close_group()
|
||||
* deallocates any system resources allocated by the system for use by
|
||||
* this task for its message queue.
|
||||
*
|
||||
@@ -68,12 +68,12 @@
|
||||
* group - Group that has the open descriptor.
|
||||
*
|
||||
* Return Value:
|
||||
* 0 (OK) if the message queue is closed successfully,
|
||||
* otherwise, -1 (ERROR).
|
||||
* Zero (OK) if the message queue is closed successfully. Otherwise, a
|
||||
* negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct inode *inode;
|
||||
@@ -93,7 +93,7 @@ int mq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
|
||||
/* Close/free the message descriptor */
|
||||
|
||||
mq_desclose_group(mqdes, group);
|
||||
nxmq_desclose_group(mqdes, group);
|
||||
|
||||
/* Get the inode from the message queue structure */
|
||||
|
||||
@@ -130,8 +130,8 @@ int mq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
* otherwise, -1 (ERROR).
|
||||
*
|
||||
* Assumptions:
|
||||
* - The behavior of a task that is blocked on either a mq_send() or
|
||||
* mq_receive() is undefined when mq_close() is called.
|
||||
* - The behavior of a task that is blocked on either a [nx]mq_send() or
|
||||
* [nx]mq_receive() is undefined when mq_close() is called.
|
||||
* - The results of using this message queue descriptor after a successful
|
||||
* return from mq_close() is undefined.
|
||||
*
|
||||
@@ -151,7 +151,17 @@ int mq_close(mqd_t mqdes)
|
||||
rtcb = (FAR struct tcb_s *)sched_self();
|
||||
DEBUGASSERT(mqdes != NULL && rtcb != NULL && rtcb->group != NULL);
|
||||
|
||||
ret = mq_close_group(mqdes, rtcb->group);
|
||||
/* Then perform the close operation */
|
||||
|
||||
ret = nxmq_close_group(mqdes, rtcb->group);
|
||||
#if 0
|
||||
if (ret < 0) /* Currently, nxmq_close_group() only returns OK */
|
||||
{
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
@@ -193,7 +203,7 @@ void mq_inode_release(FAR struct inode *inode)
|
||||
|
||||
/* Free the message queue (and any messages left in it) */
|
||||
|
||||
mq_msgqfree(msgq);
|
||||
nxmq_free_msgq(msgq);
|
||||
inode->u.i_mqueue = NULL;
|
||||
|
||||
/* Release and free the inode container. If it has been properly
|
||||
|
||||
+4
-4
@@ -164,7 +164,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
/* Create a message queue descriptor for the current thread */
|
||||
|
||||
msgq = inode->u.i_mqueue;
|
||||
mqdes = mq_descreate(NULL, msgq, oflags);
|
||||
mqdes = nxmq_create_des(NULL, msgq, oflags);
|
||||
if (!mqdes)
|
||||
{
|
||||
errcode = ENOMEM;
|
||||
@@ -208,7 +208,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
* be created with a reference count of zero.
|
||||
*/
|
||||
|
||||
msgq = (FAR struct mqueue_inode_s *)mq_msgqalloc(mode, attr);
|
||||
msgq = (FAR struct mqueue_inode_s *)nxmq_alloc_msgq(mode, attr);
|
||||
if (!msgq)
|
||||
{
|
||||
errcode = ENOSPC;
|
||||
@@ -217,7 +217,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
|
||||
/* Create a message queue descriptor for the TCB */
|
||||
|
||||
mqdes = mq_descreate(NULL, msgq, oflags);
|
||||
mqdes = nxmq_create_des(NULL, msgq, oflags);
|
||||
if (!mqdes)
|
||||
{
|
||||
errcode = ENOMEM;
|
||||
@@ -240,7 +240,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
return mqdes;
|
||||
|
||||
errout_with_msgq:
|
||||
mq_msgqfree(msgq);
|
||||
nxmq_free_msgq(msgq);
|
||||
inode->u.i_mqueue = NULL;
|
||||
|
||||
errout_with_inode:
|
||||
|
||||
Reference in New Issue
Block a user