uipc: Port Unix socket domain GC from FreeBSD.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 6 Nov 2015 07:24:22 +0000 (15:24 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 14 Nov 2015 02:55:15 +0000 (10:55 +0800)
commit2d6931c546dd00e9e952d241de832ccb3a4926c0
tree0d4b7275307f57faf5055a500d24ef66ecfdee88
parent65dd11033633049e69517c19d249df664d61e943
uipc: Port Unix socket domain GC from FreeBSD.

The new GC code records struct file in unpcb when the unpcb
is used as one of the rights.  And GC only scans all unpcbs,
instead of all files, and GC only takes unpcbs used as rights
as targets.  Unlike FreeBSD:
- We don't scan sockets on so_comp, since they are on unpcb
  global lists.
- We don't allocate a temporary array for all unreachable
  Unix domain sockets, since it could be pretty large.
  Instead, the unreachable Unix domain sockets are processed
  chunk by chunk (in the same style as our original GC code).

The original GC code is still kept around for reference
(under UNP_GC_ALLFILES).

And optimize unp_discard() a little bit by calling fdrop()
directly, if the right is not a Unix domain socket.  This is
also taken from FreeBSD.

While I'm here, reorder unpcb fields (moving most commonly
used fields to the beginning of unpcb) and add more comment.
sys/kern/uipc_usrreq.c
sys/sys/unpcb.h