diff options
-rw-r--r-- | manifest | 1 | ||||
-rw-r--r-- | usr/src/man/man9e/chpoll.9e | 32 | ||||
-rw-r--r-- | usr/src/man/man9f/Makefile | 2 | ||||
-rw-r--r-- | usr/src/man/man9f/pollhead_clean.9f | 64 | ||||
-rw-r--r-- | usr/src/uts/common/io/eventfd.c | 5 | ||||
-rw-r--r-- | usr/src/uts/common/io/inotify.c | 7 | ||||
-rw-r--r-- | usr/src/uts/common/io/timerfd.c | 5 |
7 files changed, 115 insertions, 1 deletions
@@ -19559,6 +19559,7 @@ s usr/share/man/man9f/pm_lower_power.9f=pm_raise_power.9f f usr/share/man/man9f/pm_power_has_changed.9f 0444 root bin f usr/share/man/man9f/pm_raise_power.9f 0444 root bin f usr/share/man/man9f/pm_trans_check.9f 0444 root bin +f usr/share/man/man9f/pollhead_clean.9f 0444 root bin f usr/share/man/man9f/pollwakeup.9f 0444 root bin f usr/share/man/man9f/priv_getbyname.9f 0444 root bin f usr/share/man/man9f/priv_policy.9f 0444 root bin diff --git a/usr/src/man/man9e/chpoll.9e b/usr/src/man/man9e/chpoll.9e index 868a346a99..b63f75e4e8 100644 --- a/usr/src/man/man9e/chpoll.9e +++ b/usr/src/man/man9e/chpoll.9e @@ -217,6 +217,38 @@ hold any mutex across the call to \fBpollwakeup\fR(9F) that is acquired in its the time of the call to \fBchpoll()\fR. .RE +.RS +4 +.TP +4. +In the \fBclose\fR(9E) entry point, the driver should call \fBpollwakeup()\fR +on the \fBpollhead\fR structure that corresponds to the closing software +state, specifying \fBPOLLERR\fR for the events. Further, upon return from +\fBpollwakeup()\fR, the driver's \fBclose\fR(9E) entry point should call +the \fBpollhead_clean\fR(9F) function, specifying the \fBpollhead\fR that +corresponds to the structure that will be deallocated: + +.sp +.in +2 +.nf +static int +mydriver_close(dev_t dev, int flag, int otyp, cred_t *cp) +{ + minor_t minor = getminor(dev); + mydriver_state_t *state; + + state = ddi_get_soft_state(mydriver_softstate, minor); + + pollwakeup(&state->mydriver_pollhd, POLLERR); + pollhead_clean(&state->mydriver_pollhd); + ... +.fi +.in -2 + +This step is necessary to inform other kernel subsystems that the memory +associated with the \fBpollhead\fR is about to be deallocated by the +\fBclose\fR(9E) entry point. + +.RE .SH RETURN VALUES .sp .LP diff --git a/usr/src/man/man9f/Makefile b/usr/src/man/man9f/Makefile index 1198accfda..4666def860 100644 --- a/usr/src/man/man9f/Makefile +++ b/usr/src/man/man9f/Makefile @@ -13,6 +13,7 @@ # Copyright 2011, Richard Lowe # Copyright 2013 Nexenta Systems, Inc. All rights reserved. # Copyright 2014 Garrett D'Amore <garrett@damore> +# Copyright (c) 2015 Joyent, Inc. All rights reserved. # include $(SRC)/Makefile.master @@ -392,6 +393,7 @@ MANFILES= ASSERT.9f \ pm_power_has_changed.9f \ pm_raise_power.9f \ pm_trans_check.9f \ + pollhead_clean.9f \ pollwakeup.9f \ priv_getbyname.9f \ priv_policy.9f \ diff --git a/usr/src/man/man9f/pollhead_clean.9f b/usr/src/man/man9f/pollhead_clean.9f new file mode 100644 index 0000000000..a163a65a51 --- /dev/null +++ b/usr/src/man/man9f/pollhead_clean.9f @@ -0,0 +1,64 @@ +'\" te +.\" Copyright (c) 2015, Joyent, Inc. All Rights Reserved. +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.TH POLLHEAD_CLEAN 9F "Jun 12, 1998" +.\" +.\" A little inside joke with the above date: that's the date that the +.\" devpoll work integrated (under bug 1265897). The original work included +.\" pollhead_clean() -- but didn't bother to document it! With the date, +.\" we are therefore giving this man page the date it should have had in an +.\" attempt to right an historical wrong -- albeit nearly two decades after +.\" the fact. +.\" +.SH NAME +pollhead_clean \- inform the kernel that a pollhead is being deallocated +.SH SYNOPSIS +.LP +.nf +#include <sys/poll.h> + + + +\fBvoid\fR \fBpollhead_clean\fR(\fBstruct pollhead *\fR\fIphp\fR); +.fi + +.SH INTERFACE LEVEL +.sp +.LP +Architecture independent level 1 (DDI/DKI). +.SH PARAMETERS +.sp +.ne 2 +.na +\fB\fIphp\fR\fR +.ad +.RS 9n +Pointer to a \fBpollhead\fR structure. +.RE + +.SH DESCRIPTION +.sp +.LP +The \fBpollhead_clean()\fR function informs the kernel that a driver's +\fBpollhead\fR structure is about to be deallocated, usually as part of +the driver's \fBclose\fR(9E) entry point before the software state that +contains the \fBpollhead\fR is deallocated via \fBddi_soft_state_free\fR(9F). +See \fBchpoll\fR(9E), \fBpollwakeup\fR(9E) and \fBpoll\fR(2) for more detail. +.SH CONTEXT +.sp +.LP +The \fBpollhead_clean()\fR function is generally called from the context +of a \fBclose\fR(9E) entry point, but may be called from user or kernel +context. +.SH SEE ALSO +.sp +.LP +\fBpoll\fR(2), \fBchpoll\fR(9E), \fBpollwakeup\fR(9E) + diff --git a/usr/src/uts/common/io/eventfd.c b/usr/src/uts/common/io/eventfd.c index 5c7eab54c2..6683a9ca8e 100644 --- a/usr/src/uts/common/io/eventfd.c +++ b/usr/src/uts/common/io/eventfd.c @@ -246,6 +246,11 @@ eventfd_close(dev_t dev, int flag, int otyp, cred_t *cred_p) state = ddi_get_soft_state(eventfd_softstate, minor); + if (state->efd_pollhd.ph_list != NULL) { + pollwakeup(&state->efd_pollhd, POLLERR); + pollhead_clean(&state->efd_pollhd); + } + mutex_enter(&eventfd_lock); /* diff --git a/usr/src/uts/common/io/inotify.c b/usr/src/uts/common/io/inotify.c index 8096ac0fe3..d5a48f2656 100644 --- a/usr/src/uts/common/io/inotify.c +++ b/usr/src/uts/common/io/inotify.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 Joyent, Inc. All rights reserved. */ /* @@ -1272,6 +1272,11 @@ inotify_close(dev_t dev, int flag, int otyp, cred_t *cred_p) state = ddi_get_soft_state(inotify_softstate, minor); + if (state->ins_pollhd.ph_list != NULL) { + pollwakeup(&state->ins_pollhd, POLLERR); + pollhead_clean(&state->ins_pollhd); + } + mutex_enter(&state->ins_lock); /* diff --git a/usr/src/uts/common/io/timerfd.c b/usr/src/uts/common/io/timerfd.c index 1a66929ffd..2f59c0f3e2 100644 --- a/usr/src/uts/common/io/timerfd.c +++ b/usr/src/uts/common/io/timerfd.c @@ -371,6 +371,11 @@ timerfd_close(dev_t dev, int flag, int otyp, cred_t *cred_p) state = ddi_get_soft_state(timerfd_softstate, minor); + if (state->tfd_pollhd.ph_list != NULL) { + pollwakeup(&state->tfd_pollhd, POLLERR); + pollhead_clean(&state->tfd_pollhd); + } + /* * No one can get to this timer; we don't need to lock it -- we can * just call on the backend to delete it. |