diff options
author | pjd <pjd@FreeBSD.org> | 2011-01-28 21:52:37 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-01-28 21:52:37 +0000 |
commit | 16ad1c7c691ec891024c06a2b8ef60eef1c297d8 (patch) | |
tree | 53e5e7414ba8bf8918e2a5d9ed8c6bdedccc5464 /sbin/hastd/secondary.c | |
parent | 1c569578be289f33c7a03a91a1967b84f73e73c6 (diff) | |
download | FreeBSD-src-16ad1c7c691ec891024c06a2b8ef60eef1c297d8.zip FreeBSD-src-16ad1c7c691ec891024c06a2b8ef60eef1c297d8.tar.gz |
Close all unneeded descriptors after fork(2).
MFC after: 1 week
Diffstat (limited to 'sbin/hastd/secondary.c')
-rw-r--r-- | sbin/hastd/secondary.c | 17 |
1 files changed, 11 insertions, 6 deletions
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"); |