From owner-freebsd-fs@FreeBSD.ORG Tue Feb 8 22:58:48 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 C910E106566B for ; Tue, 8 Feb 2011 22:58:48 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 5597F8FC08 for ; Tue, 8 Feb 2011 22:58:48 +0000 (UTC) Received: by bwz12 with SMTP id 12so323865bwz.13 for ; Tue, 08 Feb 2011 14:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:user-agent :mime-version:content-type; bh=cbOMrn0fmql/pi1qD06fvV+TEAcpAuGyBDIuBs4ohUk=; b=aAE1au4VCjxJk1nCzBRQKl0MzQ9gkuMb75JwPPAiSqPmBfZZ7sDQh61FquM6slqdZj 4LqDdC2Gl3WjresOL41plAOw4tBMXseYpB3X2fPOXqn8pQ5sz5vgsuULafkh1Ca1DgHb e3JauyhPAiPjAzVkSzzI+ehjMtAkReempj6E0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-type; b=EvgV4HemW1HeCxcBf6qBUXKaF1axj3YYo/NL0xQDK7DKHTVn2haT5Ou7BNf8yfZBnY 8TJR+gUWjymDR3NxR4cyORPXFnfH2b7H1NtMQzvviQTI+ariZo7KhOj1jwId+yz6CDQ+ nUguJpx3YYT3Q8l/78ZrTgdoTCbC64HmSsPjY= Received: by 10.204.98.130 with SMTP id q2mr18212860bkn.31.1297204295620; Tue, 08 Feb 2011 14:31:35 -0800 (PST) Received: from localhost ([95.69.174.185]) by mx.google.com with ESMTPS id x38sm3049507bkj.13.2011.02.08.14.31.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Feb 2011 14:31:34 -0800 (PST) From: Mikolaj Golub To: freebsd-fs@FreeBSD.org Date: Wed, 09 Feb 2011 00:31:31 +0200 Message-ID: <86lj1qgnuk.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: Pawel Jakub Dawidek Subject: 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 22:58:48 -0000 --=-=-= Hi, 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 patch. 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 :-) -- Mikolaj Golub --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=proto_uds.c.uds_accept.patch Index: sbin/hastd/proto_uds.c =================================================================== --- sbin/hastd/proto_uds.c (revision 218456) +++ sbin/hastd/proto_uds.c (working copy) @@ -201,7 +201,7 @@ uds_accept(void *ctx, void **newctxp) return (errno); fromlen = sizeof(uctx->uc_sun); - newuctx->uc_fd = accept(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun, + newuctx->uc_fd = accept(uctx->uc_fd, (struct sockaddr *)&newuctx->uc_sun, &fromlen); if (newuctx->uc_fd < 0) { ret = errno; --=-=-=--