From owner-svn-src-all@FreeBSD.ORG Sun Feb 6 23:55:09 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A8FD1065673; Sun, 6 Feb 2011 23:55:09 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 406418FC08; Sun, 6 Feb 2011 23:55:07 +0000 (UTC) Received: by fxm16 with SMTP id 16so4481211fxm.13 for ; Sun, 06 Feb 2011 15:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:x-comment-to:date :in-reply-to:message-id:user-agent:mime-version:content-type; bh=u/tbHi/XXHVPaseOQfrMY7rIZkvILK+Iaqc93H3rMy0=; b=EF1PKx/QdpCVIa7rzS6tsKN7zXJ1Pj5m5Jt8D4f1v8uI46qqoWgq6TAs7W/E6nSkpm J+aJYwDe6rJbuc7jFQPhcvx+VpTnflmhzvvcabXErMU1G+a9v0nCs4roIsaTJNHw39cO /pKjRZZ4ga+AZV7rBlrdhn0B54lq1AJvWO6UU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; b=SydEQrhro0JA/WrPtrTroM5mnL7I/6C1EBdc6wVOz9a1xTTCS7pXnXgOl8g9jyLR+W +QjZa7uEqPrmySOajvPUmdcPBPCaW16A2C6gH2NPGyQ3HzaGsKV6lTbKFkFsvM1a4M/e x2XSmcoo0HcItmWQ6jv7M9SraBIqyf2rln8/Y= Received: by 10.223.54.132 with SMTP id q4mr4452359fag.117.1296945345679; Sat, 05 Feb 2011 14:35:45 -0800 (PST) Received: from localhost ([95.69.174.185]) by mx.google.com with ESMTPS id n3sm694626faa.5.2011.02.05.14.35.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Feb 2011 14:35:43 -0800 (PST) From: Mikolaj Golub To: Pawel Jakub Dawidek References: <201101282148.p0SLmF8W001192@svn.freebsd.org> X-Comment-To: Pawel Jakub Dawidek Date: Sun, 06 Feb 2011 00:35:39 +0200 In-Reply-To: <201101282148.p0SLmF8W001192@svn.freebsd.org> (Pawel Jakub Dawidek's message of "Fri, 28 Jan 2011 21:48:15 +0000 (UTC)") Message-ID: <86aaiartxg.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: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r218041 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2011 23:55:09 -0000 --=-=-= On Fri, 28 Jan 2011 21:48:15 +0000 (UTC) Pawel Jakub Dawidek wrote: PJD> Author: pjd PJD> Date: Fri Jan 28 21:48:15 2011 PJD> New Revision: 218041 PJD> URL: http://svn.freebsd.org/changeset/base/218041 PJD> Log: PJD> Add function to close all unneeded descriptors after fork(2). PJD> PJD> MFC after: 1 week PJD> Modified: PJD> head/sbin/hastd/hastd.c PJD> head/sbin/hastd/hastd.h PJD> Modified: head/sbin/hastd/hastd.c PJD> ============================================================================== PJD> --- head/sbin/hastd/hastd.c Fri Jan 28 21:36:01 2011 (r218040) PJD> +++ head/sbin/hastd/hastd.c Fri Jan 28 21:48:15 2011 (r218041) PJD> @@ -1,6 +1,6 @@ PJD> /*- PJD> * Copyright (c) 2009-2010 The FreeBSD Foundation PJD> - * Copyright (c) 2010 Pawel Jakub Dawidek PJD> + * Copyright (c) 2010-2011 Pawel Jakub Dawidek PJD> * All rights reserved. PJD> * PJD> * This software was developed by Pawel Jakub Dawidek under sponsorship from PJD> @@ -93,6 +93,32 @@ g_gate_load(void) PJD> } PJD> } PJD> PJD> +void PJD> +descriptors_cleanup(struct hast_resource *res) PJD> +{ PJD> + struct hast_resource *tres; PJD> + PJD> + TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { PJD> + if (tres == res) { PJD> + PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY || PJD> + (res->hr_remotein == NULL && PJD> + res->hr_remoteout == NULL)); PJD> + continue; PJD> + } PJD> + if (tres->hr_remotein != NULL) PJD> + proto_close(tres->hr_remotein); PJD> + if (tres->hr_remoteout != NULL) PJD> + proto_close(tres->hr_remoteout); I think tres->hr_ctrl, hr_event, and hr_conn should be closed here too (like in the attached patch). Otherwise descriptor assertion will fail in primary if you have more than one resource, on the second resource. PJD> + } PJD> + if (cfg->hc_controlin != NULL) PJD> + proto_close(cfg->hc_controlin); PJD> + proto_close(cfg->hc_controlconn); PJD> + proto_close(cfg->hc_listenconn); PJD> + (void)pidfile_close(pfh); PJD> + hook_fini(); PJD> + pjdlog_fini(); PJD> +} PJD> + PJD> static void PJD> child_exit_log(unsigned int pid, int status) PJD> { PJD> Modified: head/sbin/hastd/hastd.h PJD> ============================================================================== PJD> --- head/sbin/hastd/hastd.h Fri Jan 28 21:36:01 2011 (r218040) PJD> +++ head/sbin/hastd/hastd.h Fri Jan 28 21:48:15 2011 (r218041) PJD> @@ -43,6 +43,8 @@ extern const char *cfgpath; PJD> extern bool sigexit_received; PJD> extern struct pidfh *pfh; PJD> PJD> +void descriptors_cleanup(struct hast_resource *res); PJD> + PJD> void hastd_primary(struct hast_resource *res); PJD> void hastd_secondary(struct hast_resource *res, struct nv *nvin); PJD> PJD> _______________________________________________ PJD> svn-src-all@freebsd.org mailing list PJD> http://lists.freebsd.org/mailman/listinfo/svn-src-all PJD> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" -- Mikolaj Golub --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=hastd.c.descriptors_cleanup.patch Index: sbin/hastd/hastd.c =================================================================== --- sbin/hastd/hastd.c (revision 218353) +++ sbin/hastd/hastd.c (working copy) @@ -109,6 +109,12 @@ descriptors_cleanup(struct hast_resource *res) proto_close(tres->hr_remotein); if (tres->hr_remoteout != NULL) proto_close(tres->hr_remoteout); + if (tres->hr_ctrl != NULL) + proto_close(tres->hr_ctrl); + if (tres->hr_event != NULL) + proto_close(tres->hr_event); + if (tres->hr_conn != NULL) + proto_close(tres->hr_conn); } if (cfg->hc_controlin != NULL) proto_close(cfg->hc_controlin); --=-=-=--