HAST: unix socket issue
Pawel Jakub Dawidek
pjd at FreeBSD.org
Tue Feb 8 23:16:40 UTC 2011
On Wed, Feb 09, 2011 at 12:31:31AM +0200, Mikolaj Golub wrote:
> Currently hastd on termination does not remove control socket file. This is
> because of the bug in uds_accept(): in accept() it passes the old sockaddr
> instead of the new one. As a result sun_path is reseted in the initial socket
> while sockaddr for the new socket is left uninitialized. See the attached
> Later when unlink is called on a socket close it fails because the path is
> empty or some garbage.
> But after fixing this issue another problem shows up, which is masked by the
> first bug: in the child process we close all unneeded descriptors. For a unix
> socket uds_close() will unlink the socket file, which we still need for
> parent. E.g. control socket file will be removed on a worker start.
> It looks like we need some way to tell uds_close() not to remove the file in
> such cases, e.g. setting a flag in socket structure before proto_close() or
> adding proto_close_without_unlink() (can't think out a good name :-)
Good catch. I fixed it a bit differently. Actually in my test with your
patch we still don't have valid socket path in sun_path.
It was of course bogus to unlink(2) socket file on each close. We should
do it only when this is descriptor we called bind(2) and listen(2) on,
not when this is descriptor created on connect(2) or accept(2). Another
problem was that after fork(2) it is wrong to unlink(2) the socket file
even for descriptor we are listening on. I fixed this by storing process
PID on bind(2), so on close we can tell if we did create socket file and
unlink it only then.
Pawel Jakub Dawidek http://www.wheelsystems.com
pjd at FreeBSD.org http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20110208/4f63080f/attachment.pgp
More information about the freebsd-fs