Module Name: src Committed By: dsl Date: Sun Oct 11 08:08:32 UTC 2009
Modified Files: src/sys/kern: tty_pty.c Log Message: Fix locking when collecting pt_read and pt_ucntl. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/kern/tty_pty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/tty_pty.c diff -u src/sys/kern/tty_pty.c:1.117 src/sys/kern/tty_pty.c:1.118 --- src/sys/kern/tty_pty.c:1.117 Fri Jun 12 09:26:50 2009 +++ src/sys/kern/tty_pty.c Sun Oct 11 08:08:32 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: tty_pty.c,v 1.117 2009/06/12 09:26:50 plunky Exp $ */ +/* $NetBSD: tty_pty.c,v 1.118 2009/10/11 08:08:32 dsl Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.117 2009/06/12 09:26:50 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.118 2009/10/11 08:08:32 dsl Exp $"); #include "opt_ptm.h" @@ -584,6 +584,7 @@ struct tty *tp = pti->pt_tty; u_char bf[BUFSIZ]; int error = 0, cc; + int c; /* * We want to block until the slave @@ -594,9 +595,10 @@ mutex_spin_enter(&tty_lock); for (;;) { if (ISSET(tp->t_state, TS_ISOPEN)) { - if (pti->pt_flags & PF_PKT && pti->pt_send) { + if (pti->pt_flags & PF_PKT && (c = pti->pt_send)) { + pti->pt_send = 0; mutex_spin_exit(&tty_lock); - error = ureadc((int)pti->pt_send, uio); + error = ureadc(c, uio); if (error) return (error); /* @@ -611,15 +613,14 @@ uiomove((void *) &tp->t_termios, cc, uio); } - pti->pt_send = 0; return (0); } - if (pti->pt_flags & PF_UCNTL && pti->pt_ucntl) { + if (pti->pt_flags & PF_UCNTL && (c = pti->pt_ucntl)) { + pti->pt_ucntl = 0; mutex_spin_exit(&tty_lock); - error = ureadc((int)pti->pt_ucntl, uio); + error = ureadc(c, uio); if (error) return (error); - pti->pt_ucntl = 0; return (0); } if (tp->t_outq.c_cc && !ISSET(tp->t_state, TS_TTSTOP))