mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
sched/mqueue/mq_desclose.c: Add a test to verify that message queue is closed by the same task group that opened it. If not, then list corruption would result. This test is only performed if CONFIG_DEBUG_FEATURES is enabled since it should not normally be an issue: It would be a strange programming practice to open a message queue in open task group, then close it in another.
This commit is contained in:
+11
-7
@@ -77,6 +77,7 @@ int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct inode *inode;
|
||||
int ret = OK;
|
||||
|
||||
DEBUGASSERT(mqdes != NULL && group != NULL);
|
||||
|
||||
@@ -93,20 +94,23 @@ int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group)
|
||||
|
||||
/* Close/free the message descriptor */
|
||||
|
||||
nxmq_desclose_group(mqdes, group);
|
||||
ret = nxmq_desclose_group(mqdes, group);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Get the inode from the message queue structure */
|
||||
|
||||
/* Get the inode from the message queue structure */
|
||||
inode = msgq->inode;
|
||||
DEBUGASSERT(inode->u.i_mqueue == msgq);
|
||||
|
||||
inode = msgq->inode;
|
||||
DEBUGASSERT(inode->u.i_mqueue == msgq);
|
||||
/* Decrement the reference count on the inode, possibly freeing it */
|
||||
|
||||
/* Decrement the reference count on the inode, possibly freeing it */
|
||||
mq_inode_release(inode);
|
||||
}
|
||||
|
||||
mq_inode_release(inode);
|
||||
sched_unlock();
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user