Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Use SESSHOLD and SESSRELE consistently.



details:   https://anonhg.NetBSD.org/src/rev/41852e1cb53f
branches:  trunk
changeset: 525525:41852e1cb53f
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 12 17:02:33 2002 +0000

description:
Use SESSHOLD and SESSRELE consistently.
Add SESSHOLD and SESSRELE to the t_session, so that we don't have dangling
references [inspired by OpenBSD].

diffstat:

 sys/kern/kern_proc.c |  13 ++++---------
 sys/kern/tty.c       |  10 +++++++---
 2 files changed, 11 insertions(+), 12 deletions(-)

diffs (80 lines):

diff -r 17350ac01f68 -r 41852e1cb53f sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c      Fri Apr 12 14:56:38 2002 +0000
+++ b/sys/kern/kern_proc.c      Fri Apr 12 17:02:33 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $   */
+/*     $NetBSD: kern_proc.c,v 1.47 2002/04/12 17:02:33 christos Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.47 2002/04/12 17:02:33 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -393,8 +393,8 @@
                                panic("enterpgrp: mksession and p != curproc");
 #endif
                } else {
+                       SESSHOLD(p->p_session);
                        pgrp->pg_session = p->p_session;
-                       pgrp->pg_session->s_count++;
                }
                pgrp->pg_id = pgid;
                LIST_INIT(&pgrp->pg_members);
@@ -447,12 +447,7 @@
            pgrp->pg_session->s_ttyp->t_pgrp == pgrp)
                pgrp->pg_session->s_ttyp->t_pgrp = NULL;
        LIST_REMOVE(pgrp, pg_hash);
-       if (--pgrp->pg_session->s_count == 0) {
-               /* Remove reference (if any) from tty to this session */
-               if (pgrp->pg_session->s_ttyp != NULL)
-                       pgrp->pg_session->s_ttyp->t_session = NULL;
-               FREE(pgrp->pg_session, M_SESSION);
-       }
+       SESSRELE(pgrp->pg_session);
        pool_put(&pgrp_pool, pgrp);
 }
 
diff -r 17350ac01f68 -r 41852e1cb53f sys/kern/tty.c
--- a/sys/kern/tty.c    Fri Apr 12 14:56:38 2002 +0000
+++ b/sys/kern/tty.c    Fri Apr 12 17:02:33 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.135 2002/03/25 04:26:43 itohy Exp $  */
+/*     $NetBSD: tty.c,v 1.136 2002/04/12 17:02:33 christos Exp $       */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.135 2002/03/25 04:26:43 itohy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.136 2002/04/12 17:02:33 christos Exp $");
 
 #include "opt_uconsole.h"
 
@@ -267,7 +267,10 @@
 
        tp->t_gen++;
        tp->t_pgrp = NULL;
-       tp->t_session = NULL;
+       if (tp->t_session != NULL) {
+               SESSRELE(tp->t_session);
+               tp->t_session = NULL;
+       }
        tp->t_state = 0;
        return (0);
 }
@@ -988,6 +991,7 @@
                    ((p->p_session->s_ttyvp || tp->t_session) &&
                     (tp->t_session != p->p_session)))
                        return (EPERM);
+               SESSHOLD(p->p_session);
                tp->t_session = p->p_session;
                tp->t_pgrp = p->p_pgrp;
                p->p_session->s_ttyp = tp;



Home | Main Index | Thread Index | Old Index