check that poll on an invalid fd doesn't hang in the dual poll case

This commit is contained in:
pooka 2011-02-20 23:45:46 +00:00
parent bfc4d64e8a
commit f8da5a9891
2 changed files with 45 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: h_client.c,v 1.2 2011/02/12 10:28:08 pooka Exp $ */
/* $NetBSD: h_client.c,v 1.3 2011/02/20 23:45:46 pooka Exp $ */
/*
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -28,10 +28,12 @@
*/
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/select.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -87,6 +89,26 @@ main(int argc, char *argv[])
if (rv != 0)
errx(1, "select2 succesful");
exit(0);
} else if (strcmp(argv[1], "invafd") == 0) {
struct pollfd pfd[2];
int fd;
fd = open("/rump/dev/null", O_RDWR);
if (fd == -1)
err(1, "open");
close(fd);
pfd[0].fd = STDIN_FILENO;
pfd[0].events = POLLIN;
pfd[1].fd = fd;
pfd[1].events = POLLIN;
if (poll(pfd, 2, INFTIM) != 1)
errx(1, "poll unexpected rv");
if (pfd[1].revents != POLLNVAL || pfd[0].revents != 0)
errx(1, "poll unexpected revents");
exit(0);
} else {
return ENOTSUP;

View File

@ -1,4 +1,4 @@
# $NetBSD: t_asyncio.sh,v 1.2 2011/02/12 10:28:08 pooka Exp $
# $NetBSD: t_asyncio.sh,v 1.3 2011/02/20 23:45:46 pooka Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@ -66,8 +66,29 @@ select_allunset_cleanup()
rump.halt
}
atf_test_case invafd cleanup
invafd_head()
{
atf_set "descr" "poll on invalid rump fd"
atf_set "timeout" "4"
}
invafd_body()
{
atf_check -s exit:0 rump_server -lrumpvfs ${RUMP_SERVER}
atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
$(atf_get_srcdir)/h_client invafd
}
invafd_cleanup()
{
rump.halt
}
atf_init_test_cases()
{
atf_add_test_case select_timeout
atf_add_test_case select_allunset
atf_add_test_case invafd
}