summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-01-28 21:52:37 +0000
committerpjd <pjd@FreeBSD.org>2011-01-28 21:52:37 +0000
commit16ad1c7c691ec891024c06a2b8ef60eef1c297d8 (patch)
tree53e5e7414ba8bf8918e2a5d9ed8c6bdedccc5464 /sbin
parent1c569578be289f33c7a03a91a1967b84f73e73c6 (diff)
downloadFreeBSD-src-16ad1c7c691ec891024c06a2b8ef60eef1c297d8.zip
FreeBSD-src-16ad1c7c691ec891024c06a2b8ef60eef1c297d8.tar.gz
Close all unneeded descriptors after fork(2).
MFC after: 1 week
Diffstat (limited to 'sbin')
-rw-r--r--sbin/hastd/primary.c17
-rw-r--r--sbin/hastd/secondary.c17
2 files changed, 22 insertions, 12 deletions
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index 7929c1f..94fbe34 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -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);
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index a722726..ae11792 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -347,7 +347,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin)
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 *res, struct nv *nvin)
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");
OpenPOWER on IntegriCloud