Date: Sat, 11 Jan 2003 00:42:26 +1100 From: Tim Robbins <tjr@FreeBSD.org> To: Juli Mallett <jmallett@FreeBSD.org> Cc: current@FreeBSD.org, re@FreeBSD.org Subject: Re: Serious issues with kqueue on sockets on CURRENT. Message-ID: <20030111004226.A36261@dilbert.robbins.dropbear.id.au> In-Reply-To: <20030110215736.A31727@dilbert.robbins.dropbear.id.au>; from tjr@FreeBSD.org on Fri, Jan 10, 2003 at 09:57:36PM %2B1100 References: <20030110013015.A23399@FreeBSD.org> <20030110215736.A31727@dilbert.robbins.dropbear.id.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 10, 2003 at 09:57:36PM +1100, Tim Robbins wrote: > On Fri, Jan 10, 2003 at 01:30:16AM -0800, Juli Mallett wrote: > > > Lately, the data field for sockets, which holds bytes ready (in the EVFILT_ > > READ case) to be read, is computed to be zero. This means that if you have > > a low watermark which is >0 per the kq, THE EVENT WILL NEVER HAPPEN. Not to > > mention that this means when the event IS triggered properly (if you can > > call it that), it is always said to have =ZERO= bytes ready. > [...] > > I can definitely reproduce this here and also fairly angry about it. > In addition to what you mentioned, fstat() gives an incorrect st_size > result now and it's likely that non-NOTE_LOWAT low watermarks are > firing too early as well. > > Ugly test program @ http://people.freebsd.org/~tjr/kq.c From what I can tell, mbufs with m_type == MT_HEADER can store data as well as those with m_type == MT_DATA. This patch corrects the tests in sbcompress(), sbdrop(), sballoc() and sbfree() so that data stored in MT_HEADER mbufs is not included in sb_ctl. I'd appreciate comments from people who have a good understanding of this code. Index: sys/kern/uipc_socket2.c =================================================================== RCS file: /x/freebsd/src/sys/kern/uipc_socket2.c,v retrieving revision 1.106 diff -u -r1.106 uipc_socket2.c --- sys/kern/uipc_socket2.c 5 Nov 2002 18:52:25 -0000 1.106 +++ sys/kern/uipc_socket2.c 10 Jan 2003 13:33:11 -0000 @@ -705,7 +705,8 @@ (unsigned)m->m_len); n->m_len += m->m_len; sb->sb_cc += m->m_len; - if (m->m_type != MT_DATA) /* XXX: Probably don't need.*/ + if (m->m_type != MT_DATA && m->m_type != MT_HEADER) + /* XXX: Probably don't need.*/ sb->sb_ctl += m->m_len; m = m_free(m); continue; @@ -776,7 +777,7 @@ m->m_len -= len; m->m_data += len; sb->sb_cc -= len; - if (m->m_type != MT_DATA) + if (m->m_type != MT_DATA && m->m_type != MT_HEADER) sb->sb_ctl -= len; break; } Index: sys/sys/socketvar.h =================================================================== RCS file: /x/freebsd/src/sys/sys/socketvar.h,v retrieving revision 1.98 diff -u -r1.98 socketvar.h --- sys/sys/socketvar.h 23 Dec 2002 22:46:47 -0000 1.98 +++ sys/sys/socketvar.h 10 Jan 2003 01:53:51 -0000 @@ -228,7 +228,7 @@ /* adjust counters in sb reflecting allocation of m */ #define sballoc(sb, m) { \ (sb)->sb_cc += (m)->m_len; \ - if ((m)->m_type != MT_DATA) \ + if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER) \ (sb)->sb_ctl += (m)->m_len; \ (sb)->sb_mbcnt += MSIZE; \ if ((m)->m_flags & M_EXT) \ @@ -238,7 +238,7 @@ /* adjust counters in sb reflecting freeing of m */ #define sbfree(sb, m) { \ (sb)->sb_cc -= (m)->m_len; \ - if ((m)->m_type != MT_DATA) \ + if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER) \ (sb)->sb_ctl -= (m)->m_len; \ (sb)->sb_mbcnt -= MSIZE; \ if ((m)->m_flags & M_EXT) \ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111004226.A36261>