Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Merge duplicate code fragments into a new lim_setcorenam...
details: https://anonhg.NetBSD.org/src/rev/591eab91b0b2
branches: trunk
changeset: 764687:591eab91b0b2
user: rmind <rmind%NetBSD.org@localhost>
date: Sun May 01 00:22:36 2011 +0000
description:
Merge duplicate code fragments into a new lim_setcorename() routine.
diffstat:
sys/kern/kern_proc.c | 15 +++------------
sys/kern/kern_resource.c | 35 ++++++++++++++++++++++-------------
sys/sys/resourcevar.h | 3 ++-
3 files changed, 27 insertions(+), 26 deletions(-)
diffs (120 lines):
diff -r ddbcaf019a45 -r 591eab91b0b2 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Sun May 01 00:11:52 2011 +0000
+++ b/sys/kern/kern_proc.c Sun May 01 00:22:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $ */
+/* $NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -1337,20 +1337,11 @@
{
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
- struct plimit *lim;
kauth_cred_t oc;
- char *cn;
/* Reset what needs to be reset in plimit. */
if (p->p_limit->pl_corename != defcorename) {
- lim_privatise(p, false);
- lim = p->p_limit;
- mutex_enter(&lim->pl_lock);
- cn = lim->pl_corename;
- lim->pl_corename = defcorename;
- mutex_exit(&lim->pl_lock);
- if (cn != defcorename)
- free(cn, M_TEMP);
+ lim_setcorename(p, defcorename, 0);
}
mutex_enter(p->p_lock);
diff -r ddbcaf019a45 -r 591eab91b0b2 sys/kern/kern_resource.c
--- a/sys/kern/kern_resource.c Sun May 01 00:11:52 2011 +0000
+++ b/sys/kern/kern_resource.c Sun May 01 00:22:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $ */
+/* $NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -699,6 +699,25 @@
}
void
+lim_setcorename(proc_t *p, char *name, size_t len)
+{
+ struct plimit *lim;
+ char *oname;
+
+ lim_privatise(p, false);
+ lim = p->p_limit;
+
+ mutex_enter(&lim->pl_lock);
+ oname = lim->pl_corename;
+ lim->pl_corename = name;
+ mutex_exit(&lim->pl_lock);
+
+ if (oname != defcorename) {
+ free(oname, M_TEMP);
+ }
+}
+
+void
lim_free(struct plimit *lim)
{
struct plimit *sv_lim;
@@ -858,17 +877,7 @@
goto done;
}
memcpy(cname, cnbuf, len);
-
- char *ocname;
- lim_privatise(p, false);
- lim = p->p_limit;
- mutex_enter(&lim->pl_lock);
- ocname = lim->pl_corename;
- lim->pl_corename = cname;
- mutex_exit(&lim->pl_lock);
- if (ocname != defcorename)
- free(ocname, M_TEMP);
-
+ lim_setcorename(p, cname, len);
done:
rw_exit(&p->p_reflock);
PNBUF_PUT(cnbuf);
diff -r ddbcaf019a45 -r 591eab91b0b2 sys/sys/resourcevar.h
--- a/sys/sys/resourcevar.h Sun May 01 00:11:52 2011 +0000
+++ b/sys/sys/resourcevar.h Sun May 01 00:22:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: resourcevar.h,v 1.49 2011/05/01 00:11:52 rmind Exp $ */
+/* $NetBSD: resourcevar.h,v 1.50 2011/05/01 00:22:36 rmind Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -110,6 +110,7 @@
struct plimit *lim_copy(struct plimit *lim);
void lim_addref(struct plimit *lim);
void lim_privatise(struct proc *p, bool set_shared);
+void lim_setcorename(struct proc *, char *, size_t);
void lim_free(struct plimit *);
void resource_init(void);
Home |
Main Index |
Thread Index |
Old Index