[comp.bugs.4bsd] SLIP driver can hang

chris@mimsy.UUCP (Chris Torek) (09/03/87)

Index:	sys/net/if_sl.c 4.3BSD Fix

Description:
	The SC_OACTIVE flag is supposed to tell whether the tty
	line is expected to call slstart() again, but it is not
	always set properly.  In particular, the CLIST_RESERVE code
	(which is not mine!) is wrong.  There is a potential problem
	in another case too, I think.

Repeat-By:
	Difficult.  I have not seen it happen myself.  If you make
	nclist very small, the bug might strike.

Fix:
	SC_OACTIVE is not necessary at all; the line switch start
	routine will be called iff the output queue is not empty.
	N.B.: this has not been tested.

RCS file: RCS/if_sl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c2 -r1.1 -r1.2
*** /tmp/,RCSt1017365	Thu Sep  3 09:47:49 1987
--- /tmp/,RCSt2017365	Thu Sep  3 09:47:50 1987
***************
*** 21,25 ****
   */
  
! /* $Header: if_sl.c,v 1.1 87/04/05 08:59:39 chris Exp $ */
  /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
  
--- 21,25 ----
   */
  
! /* $Header: if_sl.c,v 1.2 87/09/03 09:47:01 chris Exp $ */
  /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
  
***************
*** 70,74 ****
  /* flags */
  #define	SC_ESCAPED	0x0001	/* saw a FRAME_ESCAPE */
- #define	SC_OACTIVE	0x0002	/* output tty is active */
  
  #define FRAME_END	 	0300		/* Frame End */
--- 70,73 ----
***************
*** 215,219 ****
  	}
  	IF_ENQUEUE(&ifp->if_snd, m);
! 	if ((sc->sc_flags & SC_OACTIVE) == 0) {
  		splx(s);
  		slstart(sc->sc_ttyp);
--- 214,218 ----
  	}
  	IF_ENQUEUE(&ifp->if_snd, m);
! 	if (sc->sc_ttyp->t_outq.c_cc == 0) {
  		splx(s);
  		slstart(sc->sc_ttyp);
***************
*** 235,239 ****
  	register int len;
  	register u_char *cp;
! 	int flush, nd, np, n, s;
  	struct mbuf *m2;
  	extern int cfreecount;
--- 234,238 ----
  	register int len;
  	register u_char *cp;
! 	int nd, np, n, s;
  	struct mbuf *m2;
  	extern int cfreecount;
***************
*** 260,265 ****
  		 * and we have something running already, stop here.
  		 */
! 		if (cfreecount < CLISTRESERVE + SLMTU &&
! 		    sc->sc_flags & SC_OACTIVE)
  			return;
  
--- 259,263 ----
  		 * and we have something running already, stop here.
  		 */
! 		if (cfreecount < CLISTRESERVE + SLMTU && tp->t_outq.c_cc > 0)
  			return;
  
***************
*** 270,280 ****
  		IF_DEQUEUE(&sc->sc_if.if_snd, m);
  		if (m == NULL) {
- 			if (tp->t_outq.c_cc == 0)
- 				sc->sc_flags &= ~SC_OACTIVE;
  			splx(s);
  			return;
  		}
- 		flush = !(sc->sc_flags & SC_OACTIVE);
- 		sc->sc_flags |= SC_OACTIVE;
  		splx(s);
  
--- 268,274 ----
***************
*** 284,288 ****
  		 * the line may have been idle for some time.
  		 */
! 		if (flush)
  			(void) putc(FRAME_END, &tp->t_outq);
  
--- 278,282 ----
  		 * the line may have been idle for some time.
  		 */
! 		if (tp->t_outq.c_cc == 0)	/* atomic */
  			(void) putc(FRAME_END, &tp->t_outq);
  
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris