From owner-freebsd-questions@FreeBSD.ORG Wed Feb 20 23:45:48 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FEDE16A406 for ; Wed, 20 Feb 2008 23:45:48 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from snoogles.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 3E9C613C455 for ; Wed, 20 Feb 2008 23:45:48 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (localhost [127.0.0.1]) by snoogles.rachie.is-a-geek.net (Postfix) with ESMTP id 582AE1CC8B for ; Wed, 20 Feb 2008 14:45:47 -0900 (AKST) From: Mel To: freebsd-questions@freebsd.org Date: Thu, 21 Feb 2008 00:45:45 +0100 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802210045.45991.fbsd.questions@rachie.is-a-geek.net> Subject: KQueue and EVFILT_TIMER question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2008 23:45:48 -0000 Hi, I'm using a kqueue(2) that installs a timer into the queue when a certain condition has happened. This timer waits for another condition at intervals (specifically, it watches for a file to be created). Every 500ms it does a stat(2) for a given filename and when stat succeeds, I do the following: changes[0].flags |= EV_ONESHOT; changes[0].udata = (void*)1; changes[0].flags |= EV_ADD; Problem is, that this timer now never disappears, even if I replace changes[0] with a completely different event (specifically, EVFILT_VNODE on the file we now know is created). I suspect that: "This filter automatically sets the EV_CLEAR flag internally." is the culprit. So how would I go about terminating the timer? Or is the only way to initialize it as EV_ONESHOT and keep reinstalling a new one when required? Or close the kq all together and start a new one? EV_DELETE? On a related note, is the ident for a timer really used and should I increment it (all examples I've seen simply set ident to 1). -- Mel