Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2008 15:02:47 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146631 for review
Message-ID:  <200808041502.m74F2lI8064885@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146631

Change 146631 by ed@ed_flippo on 2008/08/04 15:02:26

	Move the buffer deallocation into tty_freebuffers(), which shall
	be called when closing and deallocating the TTY.

Affected files ...

.. //depot/projects/mpsafetty/sys/kern/tty.c#14 edit

Differences ...

==== //depot/projects/mpsafetty/sys/kern/tty.c#14 (text+ko) ====

@@ -112,6 +112,23 @@
 	tp->t_outlow = (ttyoutq_getsize(&tp->t_outq) * 9) / 10;
 }
 
+static void
+tty_freebuffers(struct tty *tp)
+{
+
+	/* Destroy input buffers */
+	ttyinq_flush(&tp->t_inq);
+	ttyinq_setsize(&tp->t_inq, NULL, 0);
+	MPASS(ttyinq_getsize(&tp->t_inq) == 0);
+	tp->t_inlow = 0;
+
+	/* Destroy output buffers */
+	ttyoutq_flush(&tp->t_outq);
+	ttyoutq_setsize(&tp->t_outq, NULL, 0);
+	MPASS(ttyoutq_getsize(&tp->t_outq) == 0);
+	tp->t_outlow = 0;
+}
+
 static int
 tty_drain(struct tty *tp)
 {
@@ -186,10 +203,7 @@
 	ttydisc_close(tp);
 
 	/* Destroy associated buffers already */
-	ttyinq_setsize(&tp->t_inq, NULL, 0);
-	tp->t_inlow = 0;
-	ttyoutq_setsize(&tp->t_outq, NULL, 0);
-	tp->t_outlow = 0;
+	tty_freebuffers(tp);
 
 	knlist_clear(&tp->t_inpoll.si_note, 1);
 	knlist_clear(&tp->t_outpoll.si_note, 1);
@@ -923,9 +937,7 @@
 		return;
 	}
 
-	/* Make sure we don't leak buffers */
-	MPASS(ttyinq_getsize(&tp->t_inq) == 0);
-	MPASS(ttyoutq_getsize(&tp->t_outq) == 0);
+	tty_freebuffers(tp);
 
 	/* TTY can be deallocated */
 	dev = tp->t_dev;
@@ -961,6 +973,7 @@
 void
 tty_rel_gone(struct tty *tp)
 {
+	MPASS((tp->t_flags & TF_GONE) == 0);
 
 	/* Simulate carrier removal */
 	ttydisc_modem(tp, 0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808041502.m74F2lI8064885>