Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177913592
D40955.1795565118.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D40955.1795565118.diff
View Options
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -495,7 +495,7 @@
struct vnode *vp;
struct mount *mp;
struct kinfo_file *kif;
- int error, flg, kif_sz, seals, tmp;
+ int error, flg, kif_sz, seals, tmp, got_set, got_cleared;
uint64_t bsize;
off_t foffset;
@@ -573,12 +573,12 @@
tmp &= ~FCNTLFLAGS;
tmp |= FFLAGS(arg & ~O_ACCMODE) & FCNTLFLAGS;
} while (atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0);
+ got_set = tmp & ~flg;
+ got_cleared = flg & ~tmp;
tmp = fp->f_flag & FNONBLOCK;
error = fo_ioctl(fp, FIONBIO, &tmp, td->td_ucred, td);
- if (error != 0) {
- fdrop(fp, td);
- break;
- }
+ if (error != 0)
+ goto revert_f_setfl;
tmp = fp->f_flag & FASYNC;
error = fo_ioctl(fp, FIOASYNC, &tmp, td->td_ucred, td);
if (error == 0) {
@@ -588,6 +588,13 @@
atomic_clear_int(&fp->f_flag, FNONBLOCK);
tmp = 0;
(void)fo_ioctl(fp, FIONBIO, &tmp, td->td_ucred, td);
+revert_f_setfl:
+ do {
+ tmp = flg = fp->f_flag;
+ tmp &= ~FCNTLFLAGS;
+ tmp |= got_cleared;
+ tmp &= ~got_set;
+ } while (atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0);
fdrop(fp, td);
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 25, 12:05 AM (1 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41970871
Default Alt Text
D40955.1795565118.diff (1 KB)
Attached To
Mode
D40955: During F_SETFL, don't change file flags on error
Attached
Detach File
Event Timeline