Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2008 12:00:32 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 148790 for review
Message-ID:  <200808291200.m7TC0Wii008888@repoman.freebsd.org>

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

Change 148790 by ed@ed_dull on 2008/08/29 12:00:08

	Change the hooks approach we use in ttydisc_getc_uio(). It's
	much smarter to call ttydisc_getc() here. We'll likely get more
	hooks in the future to get Netgraph working again, so if we just
	make it call ttydisc_getc(), we only need to add those hooks at
	a single location.

Affected files ...

.. //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#16 edit

Differences ...

==== //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#16 (text+ko) ====

@@ -1121,21 +1121,17 @@
 
 	/*
 	 * When a TTY hook is attached, we cannot perform unbuffered
-	 * copying to userspace. We just simulate it by copying data to
-	 * a shadow buffer.
+	 * copying to userspace. Just call ttydisc_getc() and
+	 * temporarily store data in a shadow buffer.
 	 */
 	if (ttyhook_hashook(tp, getc_capture)) {
 		while (uio->uio_resid > 0) {
 			/* Read to shadow buffer. */
-			len = ttyoutq_read(&tp->t_outq, buf,
+			len = ttydisc_getc(tp, buf,
 			    MIN(uio->uio_resid, sizeof buf));
 			if (len == 0)
 				break;
 
-			/* Process with hook. Handle sudden removal. */
-			if (ttyhook_hashook(tp, getc_capture))
-				tp->t_hook->th_getc_capture(tp, buf, len);
-
 			/* Copy to userspace. */
 			tty_unlock(tp);
 			error = uiomove(buf, len, uio);
@@ -1146,11 +1142,11 @@
 		}
 	} else {
 		error = ttyoutq_read_uio(&tp->t_outq, tp, uio);
+
+		ttydisc_wakeup_watermark(tp);
+		atomic_add_long(&tty_nout, obytes - uio->uio_resid);
 	}
 
-	ttydisc_wakeup_watermark(tp);
-	atomic_add_long(&tty_nout, obytes - uio->uio_resid);
-
 	return (error);
 }
 



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