summaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_syscalls.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-05 16:02:28 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-05 16:02:28 +0000
commit2bd7d345e3306e2e3a8559a8e61c740b13941bcf (patch)
tree9e4389e6d78e940e0f9f69eea5766eea51ebe503 /sys/nfs/nfs_syscalls.c
parent88aba8a3432b32e750331cbeae4e915673df2073 (diff)
Add counting of temporary references to a struct file (as opposed to references
from fd tables and other long-lived objects). This is to avoid races between using a file descriptor and having another process (with shared fd table) close it. We use a separate refence count so that error values from close(2) will be correctly returned to the caller of close(2). The macros for those reference counts are FILE_USE(fp) and FILE_UNUSE(fp). Make sure that the cases where closef can be called "incorrectly" (most notably dup2(2)) are handled. Right now only callers of closef (and {,p}read) use FILE_{,UN}USE correctly, more fixes incoming soon.
Diffstat (limited to 'sys/nfs/nfs_syscalls.c')
-rw-r--r--sys/nfs/nfs_syscalls.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index ae14c56ca07..1843336d880 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.25 2002/01/20 23:51:29 hugh Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.26 2002/02/05 16:02:27 art Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -781,11 +781,12 @@ nfsrv_zapsock(slp)
slp->ns_flag &= ~SLP_ALLFLAGS;
fp = slp->ns_fp;
if (fp) {
- slp->ns_fp = (struct file *)0;
+ FILE_USE(fp);
+ slp->ns_fp = NULL;
so = slp->ns_so;
so->so_upcall = NULL;
soshutdown(so, 2);
- closef(fp, (struct proc *)0);
+ closef(fp, NULL);
if (slp->ns_nam)
MFREE(slp->ns_nam, m);
m_freem(slp->ns_raw);