From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 1 18:55:35 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF0CE16A41F for ; Thu, 1 Dec 2005 18:55:35 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1137E43DA5 for ; Thu, 1 Dec 2005 18:55:26 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.3/8.13.3) with ESMTP id jB1ItFsS014560; Thu, 1 Dec 2005 10:55:15 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.3/8.13.3/Submit) id jB1ItEgj014559; Thu, 1 Dec 2005 10:55:14 -0800 (PST) (envelope-from jmg) Date: Thu, 1 Dec 2005 10:55:14 -0800 From: John-Mark Gurney To: Dmitry Agaphonov Message-ID: <20051201185514.GP885@funkthat.com> Mail-Followup-To: Dmitry Agaphonov , freebsd-hackers@freebsd.org References: <20051201150608.5e8d49f1@rzhe.agava-dubna.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051201150608.5e8d49f1@rzhe.agava-dubna.local> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org Subject: Re: Kevent(2) doesn't notify about EVFILT_WRITE filter event X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2005 18:55:35 -0000 Dmitry Agaphonov wrote this message on Thu, Dec 01, 2005 at 15:06 +0300: > I have two applications (server A and server B, A asks B for data to > serve clients) communicating via UNIX-domain socket. Testing local > clients interact to server A via UNIX-domain sockets too. Server A > uses kqueue(2) to handle clients and server B. > > When about 20 clients start requesting server A without delay, kevent(2) > doesn't notify about requested EVFILT_WRITE after only few small > requests. > > > Dumping kevent(2) changelist and eventlist gives the following: > > Server A asks for write event (with EV_ONESHOT flag set) to server B: > [13:45:36][DBG] Changing SysEvent: ident: 8, filter: -2, flags: 0x11, fflags: 0, data: 0, udata: 0x0 > [13:45:36][DBG] Received SysEvent: ident: 8, filter: -2, flags: 0x11, fflags: 0, data: 8192, udata: 0x0 > > So, the socket send buffer has 8192 bytes free. Then A sends 426 > bytes to B. > > Then server A asks for write event again: > [13:45:36][DBG] Changing SysEvent: ident: 8, filter: -2, flags: 0x11, fflags: 0, data: 0, udata: 0x0 > > After this, EVFILT_WRITE event is not returned. Noone else writes to > this socket. How it is possible? are you checking the output from the kevent that sets the sysevent? kevent if you do something "stupid" like set a _ONESHOT in kevent, and provide space for events to be returned to userland, the _ONESHOT will be immediately returned and cleared... It could also be an error is trying to be set, but can't be if you don't provide return space... so w/o seeing your code, I'd make sure when setting you are able to receive some events, and check what events you get back... > When I only turn on some additional logging which makes nothing but > logs something and thus makes some small delays between kevent(2) > calls -- all works fine, kevent(2) notifies about all write events. > > > Could anyone please give thoughts about why kevent(2) can behave so? > I have definitely no idea where the problem can be. > > This happens on FreeBSD 4.11-STABLE (cvsup'ed Nov 20 2005), SMP kernel, > P4 with HT. If you could post the parts of your code around kevent calls, I could better help you... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."