Make sure we block recursion on TTY's inwakeup callback

Suggested by:	davide
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2012-12-20 16:21:02 +00:00
parent 203d428e21
commit 3d6709a572
2 changed files with 8 additions and 1 deletions

View file

@ -797,10 +797,14 @@ ucom_inwakeup(struct tty *tp)
DPRINTF("tp=%p\n", tp);
if (ttydisc_can_bypass(tp) != 0 ||
(sc->sc_flag & UCOM_FLAG_HL_READY) == 0) {
(sc->sc_flag & UCOM_FLAG_HL_READY) == 0 ||
(sc->sc_flag & UCOM_FLAG_INWAKEUP) != 0) {
return;
}
/* prevent recursion */
sc->sc_flag |= UCOM_FLAG_INWAKEUP;
pos = sc->sc_jitterbuf_out;
while (sc->sc_jitterbuf_in != pos) {
@ -821,6 +825,8 @@ ucom_inwakeup(struct tty *tp)
if ((sc->sc_jitterbuf_in == pos) &&
(sc->sc_flag & UCOM_FLAG_RTS_IFLOW))
ucom_rts(sc, 0);
sc->sc_flag &= ~UCOM_FLAG_INWAKEUP;
}
static int

View file

@ -183,6 +183,7 @@ struct ucom_softc {
#define UCOM_FLAG_CONSOLE 0x80 /* set if device is a console */
#define UCOM_FLAG_WAIT_REFS 0x0100 /* set if we must wait for refs */
#define UCOM_FLAG_FREE_UNIT 0x0200 /* set if we must free the unit */
#define UCOM_FLAG_INWAKEUP 0x0400 /* set if we are in the tsw_inwakeup callback */
uint8_t sc_lsr;
uint8_t sc_msr;
uint8_t sc_mcr;