summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-11-17 03:07:11 +0000
committerdillon <dillon@FreeBSD.org>2001-11-17 03:07:11 +0000
commit86ed17d675cb503ddb3f71f8b6f7c3af530bb29a (patch)
treed5160b5791cda1a8cfbbcd3f5e1bd7ea97561c8f /sys/kern/sys_socket.c
parentfe91520d395f7879be049a289cbac3389fed1749 (diff)
downloadFreeBSD-src-86ed17d675cb503ddb3f71f8b6f7c3af530bb29a.zip
FreeBSD-src-86ed17d675cb503ddb3f71f8b6f7c3af530bb29a.tar.gz
Give struct socket structures a ref counting interface similar to
vnodes. This will hopefully serve as a base from which we can expand the MP code. We currently do not attempt to obtain any mutex or SX locks, but the door is open to add them when we nail down exactly how that part of it is going to work.
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index 8822fcb..04a419a 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -182,6 +182,12 @@ soo_stat(fp, ub, td)
return ((*so->so_proto->pr_usrreqs->pru_sense)(so, ub));
}
+/*
+ * API socket close on file pointer. We call soclose() to close the
+ * socket (including initiating closing protocols). soclose() will
+ * sorele() the file reference but the actual socket will not go away
+ * until the socket's ref count hits 0.
+ */
/* ARGSUSED */
int
soo_close(fp, td)
@@ -189,10 +195,12 @@ soo_close(fp, td)
struct thread *td;
{
int error = 0;
+ struct socket *so;
fp->f_ops = &badfileops;
- if (fp->f_data)
- error = soclose((struct socket *)fp->f_data);
- fp->f_data = 0;
+ if ((so = (struct socket *)fp->f_data) != NULL) {
+ fp->f_data = NULL;
+ error = soclose(so);
+ }
return (error);
}
OpenPOWER on IntegriCloud