From 86ed17d675cb503ddb3f71f8b6f7c3af530bb29a Mon Sep 17 00:00:00 2001 From: dillon Date: Sat, 17 Nov 2001 03:07:11 +0000 Subject: 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. --- sys/kern/sys_socket.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sys/kern/sys_socket.c') 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); } -- cgit v1.1