summaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-12-13 18:06:24 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-12-13 18:06:24 +0000
commitedcdcefb88a833d5170461993ee5c91a83a00ece (patch)
tree189689dbf23b94bac2f58d2fa77480096b043287 /sys/sys
parent87c1ec0a31cce6441c52f6101d99482e50aeffba (diff)
downloadsrc-test2-edcdcefb88a833d5170461993ee5c91a83a00ece.tar.gz
src-test2-edcdcefb88a833d5170461993ee5c91a83a00ece.zip
fd: fix fdrop prediction when closing a fd
Most of the time this is the last reference, contrary to typical fdrop use.
Notes
Notes: svn path=/head/; revision=368609
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/file.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 4efed9807bc8..165ca10c9f76 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -299,6 +299,17 @@ fhold(struct file *fp)
_error; \
})
+#define fdrop_close(fp, td) ({ \
+ struct file *_fp; \
+ int _error; \
+ \
+ _error = 0; \
+ _fp = (fp); \
+ if (__predict_true(refcount_release(&_fp->f_count))) \
+ _error = _fdrop(_fp, td); \
+ _error; \
+})
+
static __inline fo_rdwr_t fo_read;
static __inline fo_rdwr_t fo_write;
static __inline fo_truncate_t fo_truncate;