diff options
| author | Kelly Yancey <kbyanc@FreeBSD.org> | 2002-11-01 21:27:59 +0000 |
|---|---|---|
| committer | Kelly Yancey <kbyanc@FreeBSD.org> | 2002-11-01 21:27:59 +0000 |
| commit | e0f640e82d48be14f3f5853b7cb9c9a3c72d2497 (patch) | |
| tree | 75bdbba0cb4efffc7b7ecf3d41097ddbf79ca0f5 | |
| parent | 6cedb451fb3036d1cdd3aa22fa9560300a9f59d1 (diff) | |
Notes
| -rw-r--r-- | lib/libc/sys/kqueue.2 | 2 | ||||
| -rw-r--r-- | sys/kern/uipc_socket.c | 2 | ||||
| -rw-r--r-- | sys/sys/socketvar.h | 5 |
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index e7cde201d82c..0dae6b157cfb 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -226,7 +226,7 @@ and specifying the new low water mark in .Va data . On return, .Va data -contains the number of bytes in the socket buffer. +contains the number of bytes of protocol data available to read. .Pp If the read direction of the socket has shutdown, then the filter also sets EV_EOF in diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index e07e58191132..7a6c2b57fcdd 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1784,7 +1784,7 @@ filt_soread(struct knote *kn, long hint) { struct socket *so = (struct socket *)kn->kn_fp->f_data; - kn->kn_data = so->so_rcv.sb_cc; + kn->kn_data = so->so_rcv.sb_cc - so->so_rcv.sb_ctl; if (so->so_state & SS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; kn->kn_fflags = so->so_error; diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 15a7a0073737..4c94157a65d3 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -105,6 +105,7 @@ struct socket { u_int sb_hiwat; /* max actual char count */ u_int sb_mbcnt; /* chars of mbufs used */ u_int sb_mbmax; /* max chars of mbufs to use */ + u_int sb_ctl; /* non-data chars in buffer */ int sb_lowat; /* low water mark */ int sb_timeo; /* timeout for read/write */ short sb_flags; /* flags, see below */ @@ -227,6 +228,8 @@ struct xsocket { /* adjust counters in sb reflecting allocation of m */ #define sballoc(sb, m) { \ (sb)->sb_cc += (m)->m_len; \ + if ((m)->m_type != MT_DATA) \ + (sb)->sb_ctl += (m)->m_len; \ (sb)->sb_mbcnt += MSIZE; \ if ((m)->m_flags & M_EXT) \ (sb)->sb_mbcnt += (m)->m_ext.ext_size; \ @@ -235,6 +238,8 @@ struct xsocket { /* adjust counters in sb reflecting freeing of m */ #define sbfree(sb, m) { \ (sb)->sb_cc -= (m)->m_len; \ + if ((m)->m_type != MT_DATA) \ + (sb)->sb_ctl -= (m)->m_len; \ (sb)->sb_mbcnt -= MSIZE; \ if ((m)->m_flags & M_EXT) \ (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \ |
