From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 16 22:21:07 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 5208B16A41F for ; Fri, 16 Dec 2005 22:21:07 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id CAB0C43D62 for ; Fri, 16 Dec 2005 22:20:56 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id jBGMKj5N096999; Fri, 16 Dec 2005 16:20:45 -0600 (CST) (envelope-from dan) Date: Fri, 16 Dec 2005 16:20:45 -0600 From: Dan Nelson To: =?utf-8?B?U2XDoW4gQy4=?= Farley Message-ID: <20051216222045.GF89708@dan.emsphone.com> References: <20051216155717.W4815@thor.farley.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051216155717.W4815@thor.farley.org> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@freebsd.org Subject: Re: Number of kevents registered in kqueue X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 22:21:07 -0000 In the last episode (Dec 16), Sen C. Farley said: > I may have missed it in the man page, but I am unable to find a way > to determine how many kevents are currently registered within a > kqueue. If there is no method for a count, how about a way to find > if a kqueue is empty or not. Besides tracking what events are still > within a kqueue, this would make for an easier way to write an event > loop. Currently, calling kevent() on an empty kqueue will still > block. I don't think there's a way currently. What I did in my local tree is modify kern_kevent so that if the magic number -1 is passed in as nchanges, it will return the entire queued event list back to the caller in *eventlist, and return the number of events as the returncode. Very useful for debugging kqueue-using programs where you want to compare what you think you're waiting for, and what the kernel thinks you're waiting for :) -- Dan Nelson dnelson@allantgroup.com