summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2013-12-13 20:53:31 +0000
committermjg <mjg@FreeBSD.org>2013-12-13 20:53:31 +0000
commitb17613ac8d233de70459d2e90914ea3a7f5f87cb (patch)
tree15ff8e83e8375266f268cddde2aeb62fc48e4890 /sys/kern/kern_resource.c
parentdbd13999c50cdf66d82e4e18f09bf78ef6cd6f96 (diff)
downloadFreeBSD-src-b17613ac8d233de70459d2e90914ea3a7f5f87cb.zip
FreeBSD-src-b17613ac8d233de70459d2e90914ea3a7f5f87cb.tar.gz
rlimit: add and utilize lim_shared
MFC after: 2 weeks
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 470eaed..72b90e3 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -80,6 +80,8 @@ static int donice(struct thread *td, struct proc *chgp, int n);
static struct uidinfo *uilookup(uid_t uid);
static void ruxagg_locked(struct rusage_ext *rux, struct thread *td);
+static __inline int lim_shared(struct plimit *limp);
+
/*
* Resource controls and accounting.
*/
@@ -1129,6 +1131,14 @@ lim_hold(limp)
return (limp);
}
+static __inline int
+lim_shared(limp)
+ struct plimit *limp;
+{
+
+ return (limp->pl_refcnt > 1);
+}
+
void
lim_fork(struct proc *p1, struct proc *p2)
{
@@ -1162,7 +1172,7 @@ lim_copy(dst, src)
struct plimit *dst, *src;
{
- KASSERT(dst->pl_refcnt == 1, ("lim_copy to shared limit"));
+ KASSERT(!lim_shared(dst), ("lim_copy to shared limit"));
bcopy(src->pl_rlimit, dst->pl_rlimit, sizeof(src->pl_rlimit));
}
OpenPOWER on IntegriCloud