aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/sockbuf.h
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2014-11-12 09:57:15 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2014-11-12 09:57:15 +0000
commitcfa6009e3646cc9efc24f3b3fb2d15b4f6a6c2b5 (patch)
tree376a152fabadae344479bb291540f2dc2d1edf0d /sys/sys/sockbuf.h
parentb10cc05cf5d5fc7a0827c50a1a58265752d3edc8 (diff)
downloadsrc-cfa6009e3646cc9efc24f3b3fb2d15b4f6a6c2b5.tar.gz
src-cfa6009e3646cc9efc24f3b3fb2d15b4f6a6c2b5.zip
In preparation of merging projects/sendfile, transform bare access to
sb_cc member of struct sockbuf to a couple of inline functions: sbavail() and sbused() Right now they are equal, but once notion of "not ready socket buffer data", will be checked in, they are going to be different. Sponsored by: Netflix Sponsored by: Nginx, Inc.
Notes
Notes: svn path=/head/; revision=274421
Diffstat (limited to 'sys/sys/sockbuf.h')
-rw-r--r--sys/sys/sockbuf.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h
index ef80e9c14571..f9e8da4cde0b 100644
--- a/sys/sys/sockbuf.h
+++ b/sys/sys/sockbuf.h
@@ -166,6 +166,34 @@ int sblock(struct sockbuf *sb, int flags);
void sbunlock(struct sockbuf *sb);
/*
+ * Return how much data is available to be taken out of socket
+ * bufffer right now.
+ */
+static inline u_int
+sbavail(struct sockbuf *sb)
+{
+
+#if 0
+ SOCKBUF_LOCK_ASSERT(sb);
+#endif
+ return (sb->sb_cc);
+}
+
+/*
+ * Return how much data sits there in the socket buffer
+ * It might be that some data is not yet ready to be read.
+ */
+static inline u_int
+sbused(struct sockbuf *sb)
+{
+
+#if 0
+ SOCKBUF_LOCK_ASSERT(sb);
+#endif
+ return (sb->sb_cc);
+}
+
+/*
* How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
* This is problematical if the fields are unsigned, as the space might
* still be negative (cc > hiwat or mbcnt > mbmax). Should detect