NetBSD-Bugs archive

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

Re: kern/46522



The following reply was made to PR kern/46522; it has been noted by GNATS.

From: Nat Sloss <nathanialsloss%yahoo.com.au@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/46522
Date: Mon, 4 Jun 2012 12:36:09 +1000

 Hi,
 
 I have a marginally better patch as it was a bad idea to sleep whilst holding 
 proc_lock it would cause it to hang and be unresponsive.
 
 So this one is better:
 
 Index: sys/kern/tty.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/tty.c,v
 retrieving revision 1.250
 diff -u -r1.250 tty.c
 --- sys/kern/tty.c      12 Mar 2012 18:27:08 -0000      1.250
 +++ sys/kern/tty.c      4 Jun 2012 02:36:04 -0000
 @@ -2762,7 +2762,11 @@
  void
  tty_free(struct tty *tp)
  {
 -       int i;
 +       int i, timeout;
 +
 +       timeout = mstohz(200);
 +       if (timeout == 0)
 +               timeout = 1;
 
         mutex_enter(proc_lock);
         mutex_enter(&tty_lock);
 @@ -2770,9 +2774,11 @@
                 sigemptyset(&tp->t_sigs[i]);
         if (tp->t_sigcount != 0)
                 TAILQ_REMOVE(&tty_sigqueue, tp, t_sigqueue);
 -       mutex_exit(&tty_lock);
         mutex_exit(proc_lock);
 
 +       ttysleep(tp, &tp->t_rawcv, true, mstohz(200));
 +       mutex_exit(&tty_lock);
 +
         callout_halt(&tp->t_rstrt_ch, NULL);
         callout_destroy(&tp->t_rstrt_ch);
         ttyldisc_release(tp->t_linesw);
 
 
 Note: This patch is my own work which I submit under the NetBSD license.
 
 As an after thought it probably should panic if it has any waiters on t_rawcv.
 Is a panic better than a crash? :)
 
 Regards,
 
 Nat.
 


Home | Main Index | Thread Index | Old Index