summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorsilby <silby@FreeBSD.org>2003-06-18 18:57:58 +0000
committersilby <silby@FreeBSD.org>2003-06-18 18:57:58 +0000
commit0d0a45a41b57e28acaf0d2182e18da074cb188d1 (patch)
tree38235766c8173b7b6a2df3a0bda2222eec036cff /sys/kern/kern_descrip.c
parent591f399cfea86c008e5908349bbd5137d370f450 (diff)
downloadFreeBSD-src-0d0a45a41b57e28acaf0d2182e18da074cb188d1.zip
FreeBSD-src-0d0a45a41b57e28acaf0d2182e18da074cb188d1.tar.gz
Reserve the last 5% of file descriptors for root use. This should allow
systems to fail more gracefully when a file descriptor exhaustion situation occurs. Original patch by: David G. Andersen <dga@lcs.mit.edu> PR: 45353 MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 4c21b8b..4651631 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1192,13 +1192,14 @@ falloc(td, resultfp, resultfd)
struct proc *p = td->td_proc;
struct file *fp, *fq;
int error, i;
+ int maxuserfiles = maxfiles - (maxfiles / 20);
fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO);
sx_xlock(&filelist_lock);
- if (nfiles >= maxfiles) {
+ if (((nfiles >= maxuserfiles) && (td->td_ucred->cr_ruid != 0))
+ || (nfiles >= maxfiles)) {
sx_xunlock(&filelist_lock);
uma_zfree(file_zone, fp);
- tablefull("file");
return (ENFILE);
}
nfiles++;
OpenPOWER on IntegriCloud