diff options
author | mbr <mbr@FreeBSD.org> | 2006-09-29 09:53:19 +0000 |
---|---|---|
committer | mbr <mbr@FreeBSD.org> | 2006-09-29 09:53:19 +0000 |
commit | 06d2753424ff79d0a100d6fdaedc45e5385613a1 (patch) | |
tree | 686b1655f8c71cb61e6fe237212a55169c020638 /sys/kern/tty_pts.c | |
parent | ed48249ff4ebbb77edc175a4e3b04c4ec872bd7a (diff) | |
download | FreeBSD-src-06d2753424ff79d0a100d6fdaedc45e5385613a1.zip FreeBSD-src-06d2753424ff79d0a100d6fdaedc45e5385613a1.tar.gz |
Free tty struct after last close. This should fix the pty-leak by numbers.
Remove workarounds for tty_refcount beeing 0, this will be fixed differently
later.
Diffstat (limited to 'sys/kern/tty_pts.c')
-rw-r--r-- | sys/kern/tty_pts.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 9b1466f..12ab537 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -238,6 +238,9 @@ pty_maybecleanup(struct pt_desc *pt) if (pt->pt_ptc_open || pt->pt_pts_open) return; + if (pt->pt_tty->t_refcnt > 1) + return; + if (bootverbose) printf("destroying pty %d\n", pt->pt_num); @@ -245,6 +248,8 @@ pty_maybecleanup(struct pt_desc *pt) destroy_dev(pt->pt_devc); pt->pt_devs = pt->pt_devc = NULL; pt->pt_tty->t_dev = NULL; + ttyrel(pt->pt_tty); + pt->pt_tty = NULL; mtx_lock(&pt_mtx); pty_release(pt); @@ -378,10 +383,19 @@ ptcwakeup(struct tty *tp, int flag) static int ptcopen(struct cdev *dev, int flag, int devtype, struct thread *td) { - struct pt_desc *pt = dev->si_drv1; + struct pt_desc *pt; struct tty *tp; struct cdev *devs; + pt = dev->si_drv1; + /* + * In case we have destroyed the struct tty at the last connect time, + * we need to recreate it. + */ + if (pt->pt_tty == NULL) { + pt->pt_tty = ttyalloc(); + dev->si_tty = pt->pt_tty; + } tp = dev->si_tty; if (tp->t_oproc) return (EIO); |