Restore seperate condvars for clist i/o and clist control activity.

Fixes lockups with concurrent output to ttys. kern/37455
This commit is contained in:
ad 2007-12-22 02:21:29 +00:00
parent 392c2dc8c2
commit 4caeb79017
3 changed files with 14 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_pty.c,v 1.105 2007/12/05 17:19:58 pooka Exp $ */
/* $NetBSD: tty_pty.c,v 1.106 2007/12/22 02:21:29 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.105 2007/12/05 17:19:58 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.106 2007/12/22 02:21:29 ad Exp $");
#include "opt_compat_sunos.h"
#include "opt_ptm.h"
@ -483,7 +483,7 @@ ptsstart(tp)
}
selnotify(&pti->pt_selr, NOTE_SUBMIT);
clwakeup(&tp->t_outq);
cv_broadcast(&tp->t_outq.c_cvf);
}
/*
@ -509,11 +509,11 @@ ptsstop(tp, flush)
/* change of perspective */
if (flush & FREAD) {
selnotify(&pti->pt_selw, NOTE_SUBMIT);
clwakeup(&tp->t_rawq);
cv_broadcast(&tp->t_rawq.c_cvf);
}
if (flush & FWRITE) {
selnotify(&pti->pt_selr, NOTE_SUBMIT);
clwakeup(&tp->t_outq);
cv_broadcast(&tp->t_outq.c_cvf);
}
}
@ -527,11 +527,11 @@ ptcwakeup(tp, flag)
mutex_spin_enter(&tty_lock);
if (flag & FREAD) {
selnotify(&pti->pt_selr, NOTE_SUBMIT);
clwakeup(&tp->t_outq);
cv_broadcast(&tp->t_outq.c_cvf);
}
if (flag & FWRITE) {
selnotify(&pti->pt_selw, NOTE_SUBMIT);
clwakeup(&tp->t_rawq);
cv_broadcast(&tp->t_rawq.c_cvf);
}
mutex_spin_exit(&tty_lock);
}
@ -640,7 +640,7 @@ ptcread(dev, uio, flag)
error = EWOULDBLOCK;
goto out;
}
error = cv_wait_sig(&tp->t_outq.c_cv, &tty_lock);
error = cv_wait_sig(&tp->t_outq.c_cvf, &tty_lock);
if (error)
goto out;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_subr.c,v 1.31 2007/11/19 18:51:52 ad Exp $ */
/* $NetBSD: tty_subr.c,v 1.32 2007/12/22 02:21:29 ad Exp $ */
/*
* Copyright (c) 1993, 1994 Theo de Raadt
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.31 2007/11/19 18:51:52 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.32 2007/12/22 02:21:29 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -94,6 +94,7 @@ clalloc(struct clist *clp, int size, int quot)
clp->c_cc = 0;
cv_init(&clp->c_cv, "tty");
cv_init(&clp->c_cvf, "ttyf");
return (0);
}
@ -106,6 +107,7 @@ clfree(struct clist *clp)
free(clp->c_cq, M_TTYS);
clp->c_cs = clp->c_cq = (u_char *)0;
cv_destroy(&clp->c_cv);
cv_destroy(&clp->c_cvf);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.h,v 1.76 2007/11/19 18:51:52 ad Exp $ */
/* $NetBSD: tty.h,v 1.77 2007/12/22 02:21:30 ad Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@ -62,6 +62,7 @@ struct clist {
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
kcondvar_t c_cv; /* notifier, locked by tty lock */
kcondvar_t c_cvf; /* notifier, locked by tty lock */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};