- rawcc = RB_LEN(&tp->t_raw);
- cancc = RB_LEN(&tp->t_can);
- x = rawcc + cancc;
- if (rawcc > TTYHOG) {
- ttyflush(tp, FREAD|FWRITE);
- }
- /*
- * Block further input iff:
- * Current input > threshold AND input is available to user program
- */
- if (x >= TTYHOG/2 && (tp->t_state & TS_TBLOCK) == 0 &&
- ((tp->t_lflag&ICANON) == 0) || (cancc > 0)) {
- if (tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
- putc(tp->t_cc[VSTOP], &tp->t_out);
- }
- tp->t_state |= TS_TBLOCK; /* XXX - should be TS_RTSBLOCK? */
- ttstart(tp);
- }
+ if ((tp->t_state & TS_TBLOCK) == 0
+ && tp->t_cc[VSTOP] != _POSIX_VDISABLE
+ && putc(tp->t_cc[VSTOP], &tp->t_out) == 0)
+ tp->t_state |= TS_TBLOCK;
+ if (tp->t_cflag & CDTR_IFLOW)
+ tp->t_state |= TS_DTR_IFLOW;
+ if (tp->t_cflag & CRTS_IFLOW)
+ tp->t_state |= TS_RTS_IFLOW;
+ ttstart(tp);
+}
+
+/*
+ * Handle input low water. Send start character for the IXOFF case. Turn
+ * off our input flow control bits and propagate the change to the driver.
+ */
+/* static */
+int
+ttyunblock(tp)
+ struct tty *tp;
+{
+
+ if (tp->t_state & TS_TBLOCK
+ && tp->t_cc[VSTART] != _POSIX_VDISABLE
+ && putc(tp->t_cc[VSTART], &tp->t_out) == 0)
+ tp->t_state &= ~TS_TBLOCK;
+ tp->t_state &= ~TS_HW_IFLOW;
+ ttstart(tp);