fs: fix comment in https://github.com/apache/nuttx/pull/15163
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
40e62f4d43
commit
9c3fc91304
1 changed files with 5 additions and 13 deletions
|
@ -76,17 +76,15 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
|
||||||
|
|
||||||
filep = &list->fl_files[l1][l2];
|
filep = &list->fl_files[l1][l2];
|
||||||
#ifdef CONFIG_FS_REFCOUNT
|
#ifdef CONFIG_FS_REFCOUNT
|
||||||
int32_t refs = 0;
|
|
||||||
|
|
||||||
if (filep->f_inode != NULL)
|
if (filep->f_inode != NULL)
|
||||||
{
|
{
|
||||||
/* When the reference count is zero but the inode has not yet been
|
/* When the reference count is zero but the inode has not yet been
|
||||||
* released, At this point we should return a null pointer
|
* released, At this point we should return a null pointer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int32_t refs = atomic_read(&filep->f_refs);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
refs = atomic_read(&filep->f_refs);
|
|
||||||
if (refs == 0)
|
if (refs == 0)
|
||||||
{
|
{
|
||||||
filep = NULL;
|
filep = NULL;
|
||||||
|
@ -99,18 +97,12 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
|
||||||
{
|
{
|
||||||
filep = NULL;
|
filep = NULL;
|
||||||
}
|
}
|
||||||
else
|
else if (atomic_fetch_add(&filep->f_refs, 1) == 0)
|
||||||
{
|
{
|
||||||
do
|
atomic_fetch_add(&filep->f_refs, 1);
|
||||||
{
|
*new = true;
|
||||||
if (atomic_cmpxchg(&filep->f_refs, &refs, 2))
|
|
||||||
{
|
|
||||||
*new = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (!atomic_try_cmpxchg(&filep->f_refs, &refs, refs + 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (filep->f_inode == NULL && new == NULL)
|
if (filep->f_inode == NULL && new == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue