Subject: Fix for hole in com.c flow control state machine
To: Charles M. Hannum <mycroft@ai.mit.edu>
From: Torsten Duwe (Emacs) <duwe@immd4.informatik.uni-erlangen.de>
List: current-users
Date: 07/04/1995 00:02:26
Hi, 
	I found the flaw in the state machine: nothing changes the state of
the com from "waiting on last char(s)" to "done". If I understood the code
right the transmitter empty interrupt should do this calling comstart(),
which doesn't work in v1.60. Here is the fix:

--- src/sys/dev/isa/com.c	Wed Jun 28 09:12:32 1995
+++ /home/inf4/duwe/com.c	Tue Jul  4 01:48:51 1995
@@ -664,8 +664,7 @@
 	if ((tp->t_cflag & CRTSCTS) != 0 &&
 	    (sc->sc_msr & MSR_CTS) == 0)
 		goto out;
-	if (tp->t_outq.c_cc == 0)
-		goto out;
+	if (tp->t_outq.c_cc) {
 	tp->t_state |= TS_BUSY;
 	if (sc->sc_hwflags & COM_HW_FIFO) {
 		u_char buffer[16], *cp = buffer;
@@ -675,6 +674,7 @@
 		} while (--n);
 	} else
 		outb(iobase + com_data, getc(&tp->t_outq));
+	}
 	if (tp->t_outq.c_cc <= tp->t_lowat) {
 		if (tp->t_state & TS_ASLEEP) {
 			tp->t_state &= ~TS_ASLEEP;

(I haven't re-indented the newly-braced region for brevity's sake)

Shame on those who have downgraded to 1.56 instead of debugging.

Charles, you owe me a pizza ;-)

	Torsten