NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/46248: kevent won't return when kqueue is being closed
>Number: 46248
>Category: kern
>Synopsis: kevent won't return when kqueue is being closed
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 23 01:10:01 +0000 2012
>Originator: Julian Fagir
>Release: 6.0_BETA
>Organization:
>Environment:
NetBSD eselhitler 6.0_BETA NetBSD 6.0_BETA (ESELHITLER) #15: Fri Mar 16
12:21:49 CET 2012
gnrp@eselhitler:/home/ssd/netbsd-6.0/sys/arch/amd64/compile/obj/ESELHITLER amd64
NetBSD devrandom 6.0_BETA NetBSD 6.0_BETA (GENERIC) sparc64
>Description:
Apparently, FreeBSD and NetBSD handle kqueue'ing differently when the kqueue
underneath a kevent(2) call is closed.
On FreeBSD, closing the kqueue just succeeds and kevent returns, or whatever,
at least the close(2) call succeeds.
On NetBSD, the close won't return. If you have a pending kevent without timeout
(i.e. last field set to NULL), you won't be able to shut that call down (at
least not by this way).
>How-To-Repeat:
Save the attached program to `test.c`, and then compile and run with
`cc -lpthread test.c; time ./a.out`.
On NetBSD, this won't return until you stop it manually.
On FreeBSD, this will return after one second.
===test.c:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#include <pthread.h>
static void *
closekq(void *kq)
{
sleep(1);
close(*(int *) kq);
exit(0);
}
int
main(int argc, char *argv[])
{
int kq, event;
struct kevent kq_events;
pthread_t thr;
if ((kq = kqueue()) == -1)
err(1, "kqueue");
if (pthread_create(&thr, NULL, closekq, &kq))
err(1, "pthread_create");
event = kevent(kq, NULL, 0, &kq_events, 1, NULL);
if (event == -1)
err(1, "kevent");
return 0;
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index