Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev raise spl to IPL_HIGH when calling cngetc. Make sur...



details:   https://anonhg.NetBSD.org/src/rev/7d61c0268016
branches:  trunk
changeset: 325395:7d61c0268016
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Dec 22 18:05:40 2013 +0000

description:
raise spl to IPL_HIGH when calling cngetc.  Make sure to call
do_critpollhooks() when outputing and getting input.

diffstat:

 sys/dev/cons.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 13a5985620c1 -r 7d61c0268016 sys/dev/cons.c
--- a/sys/dev/cons.c    Sun Dec 22 17:14:22 2013 +0000
+++ b/sys/dev/cons.c    Sun Dec 22 18:05:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.c,v 1.69 2012/03/13 18:40:29 elad Exp $   */
+/*     $NetBSD: cons.c,v 1.70 2013/12/22 18:05:40 matt Exp $   */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.69 2012/03/13 18:40:29 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.70 2013/12/22 18:05:40 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -239,7 +239,15 @@
 {
        if (cn_tab == NULL)
                return (0);
-       return ((*cn_tab->cn_getc)(cn_tab->cn_dev));
+       int s = splhigh();
+       for (;;) {
+               const int rv = (*cn_tab->cn_getc)(cn_tab->cn_dev);
+               if (rv >= 0) {
+                       splx(s);
+                       return rv;
+               }
+               docritpollhooks();
+       }
 }
 
 int
@@ -297,8 +305,10 @@
 
        if (c) {
                (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
-               if (c == '\n')
+               if (c == '\n') {
+                       docritpollhooks();
                        (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index