Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Feb 2011 00:16:14 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Mikolaj Golub <to.my.trociny@gmail.com>
Cc:        freebsd-fs@FreeBSD.org
Subject:   Re: HAST: unix socket issue
Message-ID:  <20110208231614.GB1822@garage.freebsd.pl>
In-Reply-To: <86lj1qgnuk.fsf@kopusha.home.net>
References:  <86lj1qgnuk.fsf@kopusha.home.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--yNb1oOkm5a9FJOVX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 09, 2011 at 12:31:31AM +0200, Mikolaj Golub wrote:
> Hi,
>=20
> 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 so=
cket
> while sockaddr for the new socket is left uninitialized. See the attached
> patch.
>=20
> Later when unlink is called on a socket close it fails because the path is
> empty or some garbage.
>=20
> 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.
>=20
> 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.

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd@FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

--yNb1oOkm5a9FJOVX
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk1Rzr4ACgkQForvXbEpPzSBMwCggR8K9449898R9GtngNyyhSCr
oMcAoOJP73wvL7LVLFpKmkhmEW8egxEg
=41/r
-----END PGP SIGNATURE-----

--yNb1oOkm5a9FJOVX--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110208231614.GB1822>