From owner-p4-projects Wed Apr 17 11: 1:25 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0892737B405; Wed, 17 Apr 2002 11:01:19 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 45F4D37B400 for ; Wed, 17 Apr 2002 11:01:18 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3HI1Id36075 for perforce@freebsd.org; Wed, 17 Apr 2002 11:01:18 -0700 (PDT) (envelope-from jhb@freebsd.org) Date: Wed, 17 Apr 2002 11:01:18 -0700 (PDT) Message-Id: <200204171801.g3HI1Id36075@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 9921 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9921 Change 9921 by jhb@jhb_laptop on 2002/04/17 11:00:44 Only malloc newprocsig if we need it. To make this nicer we need a procsig_alloc/hold/free(drop?)/dup/shared. At some point I would like a standard naming scheme for all our refcounted objects as above. Note that if _alloc() sets the refcount appropriately, then it won't need to use separate drop/free routines. I also would like for us to use common names for all these refcount operations. Affected files ... ... //depot/projects/smpng/sys/kern/kern_exec.c#34 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_exec.c#34 (text+ko) ==== @@ -134,7 +134,7 @@ struct vattr attr; int (*img_first)(struct image_params *); struct pargs *oldargs, *newargs = NULL; - struct procsig *newprocsig = NULL; + struct procsig *oldprocsig, *newprocsig; struct vnode *tracevp = NULL, *textvp = NULL; imgp = &image_params; @@ -299,8 +299,6 @@ /* * Malloc things before we need locks. */ - MALLOC(newprocsig, struct procsig *, sizeof(struct procsig), - M_SUBPROC, M_WAITOK); newcred = crget(); i = imgp->endargs - imgp->stringbase; if (ps_arg_cache_limit >= i + sizeof(struct pargs)) @@ -318,10 +316,15 @@ PROC_LOCK(p); mp_fixme("procsig needs a lock"); if (p->p_procsig->ps_refcnt > 1) { - bcopy(p->p_procsig, newprocsig, sizeof(*newprocsig)); - p->p_procsig->ps_refcnt--; + oldprocsig = p->p_procsig; + PROC_UNLOCK(p); + MALLOC(newprocsig, struct procsig *, sizeof(struct procsig), + M_SUBPROC, M_WAITOK); + bcopy(oldprocsig, newprocsig, sizeof(*newprocsig)); + newprocsig->ps_refcnt = 1; + oldprocsig->ps_refcnt--; + PROC_LOCK(p); p->p_procsig = newprocsig; - p->p_procsig->ps_refcnt = 1; if (p->p_sigacts == &p->p_uarea->u_sigacts) panic("shared procsig but private sigacts?"); @@ -458,8 +461,6 @@ /* * Free any resources malloc'd earlier that we didn't use. */ - if (newprocsig != NULL) - FREE(newprocsig, M_SUBPROC); if (newcred == NULL) crfree(oldcred); else To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message