Re: 2.0.30 serial.c, ppp.c and pppd-2.2 questions

Rob Riggs (rriggs@tesser.com)
Sun, 20 Jul 1997 00:56:46 -0600 (MDT)


On 20-Jul-97 Rob Riggs wrote:
>> You're right that setting an overflow error is the most appropriate
>> thing to do; however, reporting an overrun error itself requires a space
>> in the flip buffer, which we won't have if the flip buffer is full.....
>
>It would be easy to make sure that we have at least one
>byte available in the flip buffer to report overruns.

Yes, I know. Following up on my own message. Almost as bad as
talking to oneself in public...

There is an easier way to handle this. The following patch
deals with this in a slightly better fashion.

-Rob

--- serial.c.orig Sun Jul 20 00:46:03 1997
+++ serial.c Sun Jul 20 00:47:13 1997
@@ -397,6 +397,20 @@
struct tty_struct *tty = info->tty;
unsigned char ch;
int ignored = 0;
+ static int flip_overflow = 0;
+
+ /*
+ * Let the tty layer know that we dropped a few bits
+ * on the floor the last time around.
+ * (rriggs@tesser.com)
+ */
+ if ((flip_overflow) && (tty->flip_count == 0) &&
+ !(info->ignore_status_mask & UART_LSR_OE)) {
+ *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+ *tty->flip.char_buf_ptr++ = 0;
+ tty->flip.count++;
+ flip_overflow = 0;
+ }

do {
ch = serial_inp(info, UART_RX);
@@ -405,8 +419,19 @@
break;
goto ignore_char;
}
- if (tty->flip.count >= TTY_FLIPBUF_SIZE)
- break;
+ /*
+ * Might as well drop the rest of data in the
+ * FIFO. We'll just be here again in no time if
+ * we don't. This will give the timer bottom-
+ * half a little more time to get its work done.
+ * (rriggs@tesser.com)
+ */
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ flip_overflow = 1;
+ if (++ignored > 100)
+ break;
+ goto ignore_char;
+ }
tty->flip.count++;
if (*status & (UART_LSR_BI)) {
#ifdef SERIAL_DEBUG_INTR
@@ -419,9 +444,16 @@
*tty->flip.flag_buf_ptr++ = TTY_PARITY;
else if (*status & UART_LSR_FE)
*tty->flip.flag_buf_ptr++ = TTY_FRAME;
- else if (*status & UART_LSR_OE)
+ /*
+ * From 2.1.x changes... deal with FIFO overrun
+ * properly. (rriggs@tesser.com)
+ */
+ else if (*status & UART_LSR_OE) {
*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
- else
+ *tty->flip.char_buf_ptr++ = 0;
+ *tty->flip.flag_buf_ptr++ = 0;
+ tty->flip.count++;
+ } else
*tty->flip.flag_buf_ptr++ = 0;
*tty->flip.char_buf_ptr++ = ch;
ignore_char: