From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 16 22:43:45 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 096A516A41F for ; Fri, 16 Dec 2005 22:43:45 +0000 (GMT) (envelope-from sean-freebsd@farley.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C7DE43D58 for ; Fri, 16 Dec 2005 22:43:40 +0000 (GMT) (envelope-from sean-freebsd@farley.org) Received: from thor.farley.org (thor.farley.org [IPv6:2001:470:1f01:290:1::5]) by mail.farley.org (8.13.1/8.13.1) with ESMTP id jBGMhcb4017482; Fri, 16 Dec 2005 16:43:38 -0600 (CST) (envelope-from sean-freebsd@farley.org) Date: Fri, 16 Dec 2005 16:43:38 -0600 (CST) From: =?ISO-8859-1?Q?Se=E1n_C=2E_Farley?= To: John-Mark Gurney In-Reply-To: <20051216222420.GI55657@funkthat.com> Message-ID: <20051216163622.S4815@thor.farley.org> References: <20051216155717.W4815@thor.farley.org> <20051216222420.GI55657@funkthat.com> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-806813850-1134773018=:4815" 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:43:45 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-806813850-1134773018=:4815 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 16 Dec 2005, John-Mark Gurney wrote: > Se=E1n C. Farley wrote this message on Fri, Dec 16, 2005 at 16:09 -0600: >> 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. > > Why do you need this? What is the point of calling kevent if you > don't have an event to wake it up? Can you give us an example of > where you need to know that there isn't any events in the queue? (I > can't think of one, since using kqueue w/o events is pointless.) I > can't see how tracking the count will let you know which events are > still in the kqueue... (second to last sentence) If you register a number of events to be handled by a single kevent-loop and they are deleted (by kevent() or EV_ONESHOT), it would be nice for a way to see if there are any more kevents registered in the kqueue when deciding to exit the loop (or program) or performing some special operation when all events are gone. >> Also, I recommend that the man page mention that a kqueue may be >> close(2)'d. The only reference that it can be is that the manual >> page says the kqueue() call returns a descriptor. > > I would think that it would need to be documented when you can't close > a descriptor.. Neither pipe nor socketpair documents that close can > be called on them... Good point. It was just a thought for us beginners to kevents. The other calls have a multitude of sources for documentation. Se=E1n --=20 sean-freebsd@farley.org --0-806813850-1134773018=:4815--