summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-09-19 17:00:25 +0000
committergreen <green@FreeBSD.org>1999-09-19 17:00:25 +0000
commit140cb4ff83b0061eeba0756f708f3f7c117e76e5 (patch)
treedbfb58e46547ab96401ba9719626c5b12448fbfd /sys/kern/uipc_syscalls.c
parentc171f3b18205ec5324a32cba54aff58ae5594701 (diff)
downloadFreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.zip
FreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.tar.gz
This is what was "fdfix2.patch," a fix for fd sharing. It's pretty
far-reaching in fd-land, so you'll want to consult the code for changes. The biggest change is that now, you don't use fp->f_ops->fo_foo(fp, bar) but instead fo_foo(fp, bar), which increments and decrements the fp refcount upon entry and exit. Two new calls, fhold() and fdrop(), are provided. Each does what it seems like it should, and if fdrop() brings the refcount to zero, the fd is freed as well. Thanks to peter ("to hell with it, it looks ok to me.") for his review. Thanks to msmith for keeping me from putting locks everywhere :) Reviewed by: peter
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 05fb328..b87114d 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1420,6 +1420,7 @@ sendfile(struct proc *p, struct sendfile_args *uap)
off_t off, xfsize, sbytes = 0;
int error = 0, s;
+ vp = NULL;
/*
* Do argument checking. Must be a regular file in, stream
* type and connected socket out, positive offset.
@@ -1435,6 +1436,7 @@ sendfile(struct proc *p, struct sendfile_args *uap)
goto done;
}
vp = (struct vnode *)fp->f_data;
+ vref(vp);
obj = vp->v_object;
if (vp->v_type != VREG || obj == NULL) {
error = EINVAL;
@@ -1698,5 +1700,7 @@ done:
if (uap->sbytes != NULL) {
copyout(&sbytes, uap->sbytes, sizeof(off_t));
}
+ if (vp)
+ vrele(vp);
return (error);
}
OpenPOWER on IntegriCloud