--- rtems-4.6.0/src/cpukit/libcsupport/src/termios.c	Thu Sep  4 20:46:58 2003
+++ rtems-4.6.0_SDEL/cpukit/libcsupport/src/termios.c	Fri Oct 31 16:34:44 2003
@@ -1039,6 +1038,7 @@ fillBufferPoll (struct rtems_termios_tty
 static rtems_status_code
 fillBufferQueue (struct rtems_termios_tty *tty)
 {
+	rtems_interrupt_level level;
 	rtems_interval timeout = tty->rawInBufSemaphoreFirstTimeout;
 	rtems_status_code sc;
         int               wait = (int)1;
@@ -1047,7 +1047,7 @@ fillBufferQueue (struct rtems_termios_tt
 		/*
 		 * Process characters read from raw queue
 		 */
-		while (tty->rawInBuf.Head != tty->rawInBuf.Tail) {
+		while ((tty->rawInBuf.Head != tty->rawInBuf.Tail) && (tty->ccount < (CBUFSIZE-1))) {
 			unsigned char c;
 			unsigned int newHead;
 
@@ -1057,6 +1057,8 @@ fillBufferQueue (struct rtems_termios_tt
 			if(((tty->rawInBuf.Tail-newHead+tty->rawInBuf.Size)
 			    % tty->rawInBuf.Size)
 			   < tty->lowwater) {
+			  /* Disable interrupt to reset FL_IREQXOF and FL_IRTSOFF without been interrupted */
+			  rtems_interrupt_disable(level);
 			  tty->flow_ctrl &= ~FL_IREQXOF;
 			  /* if tx stopped and XON should be sent... */
 			  if (((tty->flow_ctrl & (FL_MDXON | FL_ISNTXOF))
@@ -1075,6 +1077,8 @@ fillBufferQueue (struct rtems_termios_tt
 			      tty->device.startRemoteTx(tty->minor);
 			    }
 			  }
+			  /* reenable interrupts */
+			  rtems_interrupt_enable(level);
 			}
 
 			/* continue processing new character */
