summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2016-02-19 01:49:33 +0000
committermarkj <markj@FreeBSD.org>2016-02-19 01:49:33 +0000
commit32d1c3375ad5121d32b8401feaeee13981089450 (patch)
treeef3f31cabf603feda666420b4028149bee55f1ae /tests
parent1945f6646152d798789376bc8e4c57e124ea1707 (diff)
downloadFreeBSD-src-32d1c3375ad5121d32b8401feaeee13981089450.zip
FreeBSD-src-32d1c3375ad5121d32b8401feaeee13981089450.tar.gz
Ensure that we test the event condition when a disabled kevent is enabled.
r274560 modified kqueue_register() to only test the event condition if the corresponding knote is not disabled. However, this check takes place before the EV_ENABLE flag is used to clear the KN_DISABLED flag on the knote, so enabling a previously-disabled kevent would not result in a notification for a triggered event. This change fixes the problem by testing for EV_ENABLED before possibly checking the event condition. This change also updates a kqueue regression test to exercise this case. PR: 206368 Reviewed by: kib Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D5307
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/kqueue/read.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/sys/kqueue/read.c b/tests/sys/kqueue/read.c
index cc65427..2837144 100644
--- a/tests/sys/kqueue/read.c
+++ b/tests/sys/kqueue/read.c
@@ -124,15 +124,17 @@ test_kevent_socket_disable_and_enable(void)
test_begin(test_id);
- /* Add an event, then disable it. */
- EV_SET(&kev, sockfd[0], EVFILT_READ, EV_ADD, 0, 0, &sockfd[0]);
- if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
- EV_SET(&kev, sockfd[0], EVFILT_READ, EV_DISABLE, 0, 0, &sockfd[0]);
+ /*
+ * Write to the socket before adding the event. This way we can verify that
+ * enabling a triggered kevent causes the event to be returned immediately.
+ */
+ kevent_socket_fill();
+
+ /* Add a disabled event. */
+ EV_SET(&kev, sockfd[0], EVFILT_READ, EV_ADD | EV_DISABLE, 0, 0, &sockfd[0]);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
err(1, "%s", test_id);
- kevent_socket_fill();
test_no_kevents();
/* Re-enable the knote, then see if an event is generated */
OpenPOWER on IntegriCloud