summaryrefslogtreecommitdiff
path: root/sys/kern/exec_script.c
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2001-06-14 20:32:41 +0000
committerthorpej <thorpej@NetBSD.org>2001-06-14 20:32:41 +0000
commit80cc38a1afc85d777da02d63474c99fc0dc7d2c8 (patch)
tree5e815f95ae4d26b05c8550642e49130d1f4dbdef /sys/kern/exec_script.c
parent60a0137d9c548c674af6d45c5b5019d3f186af40 (diff)
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel assisted threads. What we do is stick descriptors in the table, but mark them as "larval". This causes essentially everything to treat it as a non-existent descriptor, except for fdalloc(), which sees a filled slot so that it won't (incorrectly) allocate it again. When a descriptor is fully constructed, the code that has constructed it marks it as "mature" (which actually clears the "larval" flag), and things continue to work as normal. While here, gather all the code that gets a descriptor from the table into a fd_getfile() function, and call it, rather than having the same (sometimes incorrect) code copied all over the place.
Diffstat (limited to 'sys/kern/exec_script.c')
-rw-r--r--sys/kern/exec_script.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c
index 4c9bc33743d..51b31aabf9c 100644
--- a/sys/kern/exec_script.c
+++ b/sys/kern/exec_script.c
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_script.c,v 1.27 2000/11/21 00:37:56 jdolecek Exp $ */
+/* $NetBSD: exec_script.c,v 1.28 2001/06/14 20:32:47 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -187,6 +187,7 @@ check_shell:
fp->f_ops = &vnops;
fp->f_data = (caddr_t) epp->ep_vp;
fp->f_flag = FREAD;
+ FILE_SET_MATURE(fp);
FILE_UNUSE(fp, p);
}
#endif