Date: Sun, 06 Feb 2011 00:35:39 +0200 From: Mikolaj Golub <to.my.trociny@gmail.com> To: Pawel Jakub Dawidek <pjd@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r218041 - head/sbin/hastd Message-ID: <86aaiartxg.fsf@kopusha.home.net> In-Reply-To: <201101282148.p0SLmF8W001192@svn.freebsd.org> (Pawel Jakub Dawidek's message of "Fri, 28 Jan 2011 21:48:15 %2B0000 (UTC)") References: <201101282148.p0SLmF8W001192@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= 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@FreeBSD.org> PJD> + * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pjd@FreeBSD.org> 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); --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86aaiartxg.fsf>