From 2bd7d345e3306e2e3a8559a8e61c740b13941bcf Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Tue, 5 Feb 2002 16:02:28 +0000 Subject: 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. --- sys/nfs/nfs_syscalls.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/nfs/nfs_syscalls.c') 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); -- cgit v1.2.3