From edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c Mon Sep 17 00:00:00 2001 From: visa Date: Fri, 21 Jun 2019 09:39:48 +0000 Subject: Make resource limit access MP-safe. So far, the copy-on-write sharing of resource limit structs has been done between processes. By applying copy-on-write also between threads, threads can read rlimits in a nearly lock-free manner. Inspired by code in DragonFly BSD and FreeBSD. OK mpi@, agreement from jmatthew@ and anton@ --- sys/kern/sys_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/kern/sys_generic.c') diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index ccb8502ed21..5fb4cf04258 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.123 2019/01/21 23:41:26 cheloha Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.124 2019/06/21 09:39:48 visa Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -935,7 +935,7 @@ doppoll(struct proc *p, struct pollfd *fds, u_int nfds, int timo, ncoll, i, s, error; /* Standards say no more than MAX_OPEN; this is possibly better. */ - if (nfds > min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles)) + if (nfds > min((int)lim_cur(RLIMIT_NOFILE), maxfiles)) return (EINVAL); /* optimize for the default case, of a small nfds value */ -- cgit v1.2.3-59-g8ed1b