Correct a reference counting error in mq_open()

This commit is contained in:
Gregory Nutt
2015-09-23 10:34:08 -06:00
parent c52e3e017b
commit cc7130b836
12 changed files with 42 additions and 15 deletions
+9 -3
View File
@@ -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();