Readd rev. 1.145 because of vfs bugs and races near revoke(). Until they

are fixed we can't free any slaves. Add a workaround to not to leak ptys
by number.
This commit is contained in:
Martin Blapp 2006-09-30 22:51:05 +00:00
parent 8ed6451eab
commit 570d6457d1

View File

@ -184,7 +184,11 @@ static void
pty_maybe_destroy_slave(struct ptsc *pt)
{
if (pt->pt_devc_open == 0 && pt->pt_devs_open == 0)
/*
* vfs bugs and complications near revoke() make
* it currently impossible to destroy struct cdev
*/
if (0 && pt->pt_devc_open == 0 && pt->pt_devs_open == 0)
pty_destroy_slave(pt);
}
@ -328,12 +332,18 @@ ptcopen(struct cdev *dev, int flag, int devtype, struct thread *td)
pt->pt_tty = ttyalloc();
pt->pt_tty->t_sc = pt;
dev->si_tty = pt->pt_tty;
pty_create_slave(td->td_ucred, pt, minor(dev));
}
tp = dev->si_tty;
if (tp->t_oproc)
if (tp->t_oproc) {
/*
* Only return if we have a non empty
* state to avoid leakage. Workaround for
* vfs bugs and complications near revoke().
*/
if (tp->t_state != 0x0 || tp->t_refcnt > 1)
return (EIO);
}
tp->t_timeout = -1;
tp->t_oproc = ptsstart;
tp->t_stop = ptsstop;