From owner-freebsd-fs@FreeBSD.ORG Tue Feb 8 23:16:40 2011 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47CC8106564A for ; Tue, 8 Feb 2011 23:16:40 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.garage.freebsd.pl (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id E626A8FC12 for ; Tue, 8 Feb 2011 23:16:39 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 16BEC45E87; Wed, 9 Feb 2011 00:16:38 +0100 (CET) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 0443745CA6; Wed, 9 Feb 2011 00:16:32 +0100 (CET) Date: Wed, 9 Feb 2011 00:16:14 +0100 From: Pawel Jakub Dawidek To: Mikolaj Golub Message-ID: <20110208231614.GB1822@garage.freebsd.pl> References: <86lj1qgnuk.fsf@kopusha.home.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yNb1oOkm5a9FJOVX" Content-Disposition: inline In-Reply-To: <86lj1qgnuk.fsf@kopusha.home.net> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 9.0-CURRENT amd64 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: freebsd-fs@FreeBSD.org Subject: Re: HAST: unix socket issue X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2011 23:16:40 -0000 --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--