diff options
| author | Matthew Dillon <dillon@FreeBSD.org> | 2001-11-17 03:07:11 +0000 |
|---|---|---|
| committer | Matthew Dillon <dillon@FreeBSD.org> | 2001-11-17 03:07:11 +0000 |
| commit | b1e4abd2464bb5552ab1c65f9574adb61d9a36fd (patch) | |
| tree | d5160b5791cda1a8cfbbcd3f5e1bd7ea97561c8f /sys/kern/sys_socket.c | |
| parent | 720c992fe1f48db62dda58802c5bca3578be4d38 (diff) | |
Notes
Diffstat (limited to 'sys/kern/sys_socket.c')
| -rw-r--r-- | sys/kern/sys_socket.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 8822fcbdd278..04a419a8f484 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); } |
