From jimmy@mammothcheese.ca  Mon Jun  7 00:04:40 2010
Return-Path: <jimmy@mammothcheese.ca>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E20EF1065672
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Jun 2010 00:04:40 +0000 (UTC)
	(envelope-from jimmy@mammothcheese.ca)
Received: from smtp105.rog.mail.re2.yahoo.com (smtp105.rog.mail.re2.yahoo.com [206.190.36.83])
	by mx1.freebsd.org (Postfix) with SMTP id 8B3CC8FC15
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Jun 2010 00:04:40 +0000 (UTC)
Received: (qmail 56775 invoked from network); 7 Jun 2010 00:04:39 -0000
Received: from _HOSTNAME_ (jimmy@99.255.2.249 with login)
        by smtp105.rog.mail.re2.yahoo.com with SMTP; 06 Jun 2010 17:04:38 -0700 PDT
Received: by _HOSTNAME_ (sSMTP sendmail emulation); Sun, 06 Jun 2010 20:04:38 -0400
Message-Id: <730490.56672.qm@smtp105.rog.mail.re2.yahoo.com>
Date: Sun, 06 Jun 2010 20:04:38 -0400
From: "James Bailie" <jimmy@mammothcheese.ca>
Reply-To: James Bailie <jimmy@mammothcheese.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: kqueue timer events are not deleted when associated descriptor is closed
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         147604
>Category:       kern
>Synopsis:       [kqueue] kqueue timer events are not deleted when associated descriptor is closed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 07 00:10:02 UTC 2010
>Closed-Date:    Fri Jun 25 21:03:36 UTC 2010
>Last-Modified:  Fri Jun 25 21:03:36 UTC 2010
>Originator:     James Bailie
>Release:        FreeBSD 8.1-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD localhost 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #20: Sat May 29 13:36:02 EDT 2010 root@localhost:/usr/obj/usr/src/sys/LOCAL amd64


	
>Description:
Timer events set with kevent() do not get deleted when the associated descriptor is
closed.  If this behavior is intentional, then the manual page should be modified to
reflect this. 

>How-To-Repeat:
--- test.c begins here ---
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

int main( int argc, char **argv )
{
   struct kevent inqueue[ 1 ], outqueue[ 1 ];
   int kq, inq;

   if (( kq = kqueue()) < 0 )
   {
      fprintf( stderr, "kqueue(): %s", strerror( errno ));
      exit( 1 );
   }

   inqueue[ 0 ].ident = 0;
   inqueue[ 0 ].filter = EVFILT_TIMER;
   inqueue[ 0 ].fflags = 0;
   inqueue[ 0 ].data = 1000;
   inqueue[ 0 ].flags = EV_ADD | EV_ENABLE;
   inqueue[ 0 ].udata = NULL;

   for( inq = 1; ; inq = 0 )
   {
      if ( kevent( kq, inqueue, inq, outqueue, 1, NULL ) > 0 &&
           outqueue[ 0 ].filter == EVFILT_TIMER )
      {
         write( 1, "TIMEOUT\n", 8 );

         if ( inq )
            close( 0 );
      }
   }
}
--- test.c ends here ---
>Fix:
	
>Release-Note:
>Audit-Trail:

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, jimmy@mammothcheese.ca
Cc:  
Subject: Re: kern/147604: [kqueue] kqueue timer events are not deleted when
 associated descriptor is closed
Date: Sat, 19 Jun 2010 15:53:02 +0200

 The way I read the man page, the ident for EVFILT_TIMER is an arbitrary
 number and is unrelated to file descriptors. In that case, the
 implementation is correct.
 
 Note, for example, that EVFILT_PROC does not take a file descriptor
 either, but a process ID.
 
 -- 
 Jilles Tjoelker
State-Changed-From-To: open->closed 
State-Changed-By: jilles 
State-Changed-When: Fri Jun 25 21:03:34 UTC 2010 
State-Changed-Why:  
Submitter confirms the manual is fine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=147604 
>Unformatted:
