lkml.org 
[lkml]   [1998]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [2.1.113] What is CHECK_TTY_COUNT warning me about?
Date
As it happens I sent a patch to Linus for 2.1.115 (which hasn't been
applied ;( ) that fixes this. It has to to do with the DEV_SYSCONS code
so you can blaim the bug on me :)

Hi Linus,

ever since you accepted my serial console code into the kernel
I have seen intermittant

rs_close: bad serial port count for ttys0: -1

warning messages from the serial driver. I've finally found out what it
is - it has to do with the fact that, when we hangup a serial port that
is the console (say ttyS0) we do not hang up processes that connected
to /dev/console instead (that is good). As a result, some usage counters in
serial.c were out of sync with counters in tty_io.c

Here's a patch that fixes the problem:

--- linux-2.1.113/drivers/char/tty_io.c.orig Mon Aug 3 20:44:21 1998
+++ linux-2.1.113/drivers/char/tty_io.c Mon Aug 3 21:11:08 1998
@@ -375,8 +375,10 @@
{
struct tty_struct *tty = (struct tty_struct *) data;
struct file * filp;
+ struct file * cons_filp = NULL;
struct task_struct *p;
unsigned long flags;
+ int closecount = 0, n;

if (!tty)
return;
@@ -392,10 +394,13 @@
if (!filp->f_dentry->d_inode)
continue;
if (filp->f_dentry->d_inode->i_rdev == CONSOLE_DEV ||
- filp->f_dentry->d_inode->i_rdev == SYSCONS_DEV)
+ filp->f_dentry->d_inode->i_rdev == SYSCONS_DEV) {
+ cons_filp = filp;
continue;
+ }
if (filp->f_op != &tty_fops)
continue;
+ closecount++;
tty_fasync(filp, 0);
filp->f_op = &hung_up_tty_fops;
}
@@ -447,7 +452,11 @@
tty->session = 0;
tty->pgrp = -1;
tty->ctrl_status = 0;
- if (tty->driver.hangup)
+ if (cons_filp) {
+ if (tty->driver.close)
+ for (n = 0; n < closecount; n++)
+ tty->driver.close(tty, cons_filp);
+ } else if (tty->driver.hangup)
(tty->driver.hangup)(tty);
restore_flags(flags);
}

Mike.
--
Miquel van Smoorenburg | Our vision is to speed up time,
miquels@cistron.nl | eventually eliminating it. <*>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:43    [from the cache]
©2003-2011 Jasper Spaans