From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 5 16:04:03 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CF0E0990 for ; Tue, 5 Mar 2013 16:04:03 +0000 (UTC) (envelope-from erdgeist@erdgeist.org) Received: from elektropost.org (elektropost.org [217.13.206.130]) by mx1.freebsd.org (Postfix) with ESMTP id 22802AA6 for ; Tue, 5 Mar 2013 16:04:02 +0000 (UTC) Received: (qmail 7757 invoked from network); 5 Mar 2013 16:03:55 -0000 Received: from elektropost.org (HELO elektropost.org) (erdgeist@erdgeist.org) by elektropost.org with AES256-SHA encrypted SMTP; 5 Mar 2013 16:03:55 -0000 Date: Tue, 5 Mar 2013 17:03:31 +0100 (CET) From: Dirk Engling To: freebsd-hackers@freebsd.org Subject: pop filters from kqueue Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2013 16:04:03 -0000 Dear fellow FreeBSD hackers, while writing a daemon that uses a kqueue to keep track of forked processes and pipes to userland client code etc, I noticed a lack of features to implement a proper shutdown without holding data redundantly. When my daemon quits, I can not ask the kqueue for my installed filters and get back the udata I passed to the kqueue. This is unfortunate, because I like the idea of having only one owner per memory allocation. The most obvious use would be a per-fd-state held in a memory block. When passing it to kevent() via the udata entry, I would make this filter the owner of my allocation. However, when gracefully shutting down, my daemon has no way of retrieving all the values passed to the filters. For most cases that may be okay: memory allocations will just be thrown away on exit(), anyway. But once I need to clean up external state, like sending signals to processes I installed an EVFILT_PROC for etc, I need to keep a redundant list of pids and the associated udata. This violates the rule of strict ownership and introduces room for inconsistencies. Is there a specific reason I have overlooked that would forbid popping untriggered filters from my kqueue? Or is there even a way to do so that I have missed? Regards, erdgeist