1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-01 08:27:59 +00:00

- Use an acquire barrier to increment f_count in fget_unlocked and

remove the volatile cast.  Describe the reason in detail in a comment.

Discussed with:	bde, jhb
This commit is contained in:
Jeff Roberson 2009-06-02 06:55:32 +00:00
parent f08e28cfc6
commit f4471727f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193301

View File

@ -2075,9 +2075,13 @@ fget_unlocked(struct filedesc *fdp, int fd)
count = fp->f_count;
if (count == 0)
continue;
if (atomic_cmpset_int(&fp->f_count, count, count + 1) != 1)
/*
* Use an acquire barrier to prevent caching of fd_ofiles
* so it is refreshed for verification.
*/
if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1)
continue;
if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd])
if (fp == fdp->fd_ofiles[fd])
break;
fdrop(fp, curthread);
}