mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Correct a reference counting error in mq_open()
This commit is contained in:
+9
-3
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* fs/mqueue/mq_open.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -139,7 +139,8 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
sched_lock();
|
||||
|
||||
/* Get the inode for this mqueue. This should succeed if the message
|
||||
* queue has already been created.
|
||||
* queue has already been created. In this case, inode_finde() will
|
||||
* have incremented the reference count on the inode.
|
||||
*/
|
||||
|
||||
inode = inode_find(fullpath, &relpath);
|
||||
@@ -206,7 +207,9 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Allocate memory for the new message queue. */
|
||||
/* Allocate memory for the new message queue. The new inode will
|
||||
* be created with a reference count of zero.
|
||||
*/
|
||||
|
||||
msgq = (FAR struct mqueue_inode_s*)mq_msgqalloc(mode, attr);
|
||||
if (!msgq)
|
||||
@@ -230,6 +233,9 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
inode->u.i_mqueue = msgq;
|
||||
msgq->inode = inode;
|
||||
|
||||
/* Set the initial reference count on this inode to one */
|
||||
|
||||
inode->i_crefs = 1;
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
|
||||
Reference in New Issue
Block a user