r334853 added a "socket destructor" callback. However, as implemented, it
was really a "socket close" callback. Update the socket destructor functionality to run when a socket is destroyed (rather than when it is closed). The original submitter has confirmed that this change satisfies the intended use case. Suggested by: rwatson Submitted by: Michio Honda <micchie at sfc.wide.ad.jp> Tested by: Michio Honda <micchie at sfc.wide.ad.jp> Approved by: re (kib) Differential Revision: https://reviews.freebsd.org/D17590
This commit is contained in:
parent
c35b07d1cb
commit
e77f0bdcb5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339419
@ -26,7 +26,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 8, 2018
|
.Dd October 18, 2018
|
||||||
.Dt SOCKET 9
|
.Dt SOCKET 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -378,8 +378,8 @@ or
|
|||||||
A kernel system can use the
|
A kernel system can use the
|
||||||
.Fn sodtor_set
|
.Fn sodtor_set
|
||||||
function to set a destructor for a socket.
|
function to set a destructor for a socket.
|
||||||
The destructor is called when the socket is closed.
|
The destructor is called when the socket is is about to be freed.
|
||||||
The destructor is called after the protocol close routine has completed.
|
The destructor is called before the protocol detach routine.
|
||||||
The destructor can serve as a callback to initiate additional cleanup actions.
|
The destructor can serve as a callback to initiate additional cleanup actions.
|
||||||
.Ss Socket I/O
|
.Ss Socket I/O
|
||||||
The
|
The
|
||||||
|
@ -1026,6 +1026,9 @@ sofree(struct socket *so)
|
|||||||
so->so_error = ECONNABORTED;
|
so->so_error = ECONNABORTED;
|
||||||
SOCK_UNLOCK(so);
|
SOCK_UNLOCK(so);
|
||||||
|
|
||||||
|
if (so->so_dtor != NULL)
|
||||||
|
so->so_dtor(so);
|
||||||
|
|
||||||
VNET_SO_ASSERT(so);
|
VNET_SO_ASSERT(so);
|
||||||
if (pr->pr_flags & PR_RIGHTS && pr->pr_domain->dom_dispose != NULL)
|
if (pr->pr_flags & PR_RIGHTS && pr->pr_domain->dom_dispose != NULL)
|
||||||
(*pr->pr_domain->dom_dispose)(so);
|
(*pr->pr_domain->dom_dispose)(so);
|
||||||
@ -1102,8 +1105,6 @@ soclose(struct socket *so)
|
|||||||
drop:
|
drop:
|
||||||
if (so->so_proto->pr_usrreqs->pru_close != NULL)
|
if (so->so_proto->pr_usrreqs->pru_close != NULL)
|
||||||
(*so->so_proto->pr_usrreqs->pru_close)(so);
|
(*so->so_proto->pr_usrreqs->pru_close)(so);
|
||||||
if (so->so_dtor != NULL)
|
|
||||||
so->so_dtor(so);
|
|
||||||
|
|
||||||
SOCK_LOCK(so);
|
SOCK_LOCK(so);
|
||||||
if ((listening = (so->so_options & SO_ACCEPTCONN))) {
|
if ((listening = (so->so_options & SO_ACCEPTCONN))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user