Notify all sleeping threads of device removal in krping.
Implement d_purge for krping_cdevsw. Submitted by: slavash@ MFC after: 3 days Sponsored by: Mellanox Technologies
This commit is contained in:
parent
c5672dd7b9
commit
e8f206cc60
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352954
@ -2189,3 +2189,17 @@ krping_walk_cb_list(void (*f)(struct krping_stats *, void *), void *arg)
|
||||
(*f)(cb->pd ? &cb->stats : NULL, arg);
|
||||
mutex_unlock(&krping_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
krping_cancel_all(void)
|
||||
{
|
||||
struct krping_cb *cb;
|
||||
|
||||
mutex_lock(&krping_mutex);
|
||||
list_for_each_entry(cb, &krping_cbs, list) {
|
||||
cb->state = ERROR;
|
||||
wake_up_interruptible(&cb->sem);
|
||||
}
|
||||
mutex_unlock(&krping_mutex);
|
||||
}
|
||||
|
||||
|
@ -17,3 +17,4 @@ struct krping_stats {
|
||||
int krping_doit(char *);
|
||||
void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *);
|
||||
int krping_sigpending(void);
|
||||
void krping_cancel_all(void);
|
||||
|
@ -40,6 +40,7 @@ static d_open_t krping_open;
|
||||
static d_close_t krping_close;
|
||||
static d_read_t krping_read;
|
||||
static d_write_t krping_write;
|
||||
static d_purge_t krping_purge;
|
||||
|
||||
/* Character device entry points */
|
||||
static struct cdevsw krping_cdevsw = {
|
||||
@ -48,6 +49,7 @@ static struct cdevsw krping_cdevsw = {
|
||||
.d_close = krping_close,
|
||||
.d_read = krping_read,
|
||||
.d_write = krping_write,
|
||||
.d_purge = krping_purge,
|
||||
.d_name = "krping",
|
||||
};
|
||||
|
||||
@ -210,6 +212,13 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
return(err);
|
||||
}
|
||||
|
||||
static void
|
||||
krping_purge(struct cdev *dev __unused)
|
||||
{
|
||||
|
||||
krping_cancel_all();
|
||||
}
|
||||
|
||||
int
|
||||
krping_sigpending(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user