diff options
author | glebius <glebius@FreeBSD.org> | 2014-11-12 09:57:15 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2014-11-12 09:57:15 +0000 |
commit | c0b38b545a543b8ec276ed09783b02222303d543 (patch) | |
tree | 376a152fabadae344479bb291540f2dc2d1edf0d /sys/sys/sockbuf.h | |
parent | 14548525ed746ca00565a8c2f499c9659d2650f2 (diff) | |
download | FreeBSD-src-c0b38b545a543b8ec276ed09783b02222303d543.zip FreeBSD-src-c0b38b545a543b8ec276ed09783b02222303d543.tar.gz |
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.
Diffstat (limited to 'sys/sys/sockbuf.h')
-rw-r--r-- | sys/sys/sockbuf.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index ef80e9c..f9e8da4 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 |