From owner-svn-src-head@FreeBSD.ORG Fri Jan 28 21:52:37 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7D14106564A; Fri, 28 Jan 2011 21:52:37 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D5928FC23; Fri, 28 Jan 2011 21:52:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0SLqb0e001392; Fri, 28 Jan 2011 21:52:37 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0SLqbs1001389; Fri, 28 Jan 2011 21:52:37 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201101282152.p0SLqbs1001389@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Fri, 28 Jan 2011 21:52:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218043 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2011 21:52:37 -0000 Author: pjd Date: Fri Jan 28 21:52:37 2011 New Revision: 218043 URL: http://svn.freebsd.org/changeset/base/218043 Log: Close all unneeded descriptors after fork(2). MFC after: 1 week Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Fri Jan 28 21:51:40 2011 (r218042) +++ head/sbin/hastd/primary.c Fri Jan 28 21:52:37 2011 (r218043) @@ -790,7 +790,7 @@ hastd_primary(struct hast_resource *res) { pthread_t td; pid_t pid; - int error; + int error, mode; /* * Create communication channel between parent and child. @@ -822,19 +822,24 @@ hastd_primary(struct hast_resource *res) /* This is parent. */ /* Declare that we are receiver. */ proto_recv(res->hr_event, NULL, 0); + /* Declare that we are sender. */ + proto_send(res->hr_ctrl, NULL, 0); res->hr_workerpid = pid; return; } gres = res; - - (void)pidfile_close(pfh); - hook_fini(); - - setproctitle("%s (primary)", res->hr_name); + mode = pjdlog_mode_get(); /* Declare that we are sender. */ proto_send(res->hr_event, NULL, 0); + /* Declare that we are receiver. */ + proto_recv(res->hr_ctrl, NULL, 0); + descriptors_cleanup(res); + + pjdlog_init(mode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); + setproctitle("%s (primary)", res->hr_name); init_local(res); init_ggate(res); Modified: head/sbin/hastd/secondary.c ============================================================================== --- head/sbin/hastd/secondary.c Fri Jan 28 21:51:40 2011 (r218042) +++ head/sbin/hastd/secondary.c Fri Jan 28 21:52:37 2011 (r218043) @@ -347,7 +347,7 @@ hastd_secondary(struct hast_resource *re sigset_t mask; pthread_t td; pid_t pid; - int error; + int error, mode; /* * Create communication channel between parent and child. @@ -380,23 +380,28 @@ hastd_secondary(struct hast_resource *re res->hr_remoteout = NULL; /* Declare that we are receiver. */ proto_recv(res->hr_event, NULL, 0); + /* Declare that we are sender. */ + proto_send(res->hr_ctrl, NULL, 0); res->hr_workerpid = pid; return; } gres = res; + mode = pjdlog_mode_get(); - (void)pidfile_close(pfh); - hook_fini(); + /* Declare that we are sender. */ + proto_send(res->hr_event, NULL, 0); + /* Declare that we are receiver. */ + proto_recv(res->hr_ctrl, NULL, 0); + descriptors_cleanup(res); + pjdlog_init(mode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); setproctitle("%s (secondary)", res->hr_name); PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); - /* Declare that we are sender. */ - proto_send(res->hr_event, NULL, 0); - /* Error in setting timeout is not critical, but why should it fail? */ if (proto_timeout(res->hr_remotein, 0) < 0) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");