mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-06 18:29:47 +00:00
Close all unneeded descriptors after fork(2).
MFC after: 1 week
This commit is contained in:
parent
d64c0992e4
commit
da1783ea29
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=218043
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user