svn commit: r218041 - head/sbin/hastd
Pawel Jakub Dawidek
pjd at FreeBSD.org
Fri Jan 28 21:48:15 UTC 2011
Author: pjd
Date: Fri Jan 28 21:48:15 2011
New Revision: 218041
URL: http://svn.freebsd.org/changeset/base/218041
Log:
Add function to close all unneeded descriptors after fork(2).
MFC after: 1 week
Modified:
head/sbin/hastd/hastd.c
head/sbin/hastd/hastd.h
Modified: head/sbin/hastd/hastd.c
==============================================================================
--- head/sbin/hastd/hastd.c Fri Jan 28 21:36:01 2011 (r218040)
+++ head/sbin/hastd/hastd.c Fri Jan 28 21:48:15 2011 (r218041)
@@ -1,6 +1,6 @@
/*-
* Copyright (c) 2009-2010 The FreeBSD Foundation
- * Copyright (c) 2010 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+ * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
@@ -93,6 +93,32 @@ g_gate_load(void)
}
}
+void
+descriptors_cleanup(struct hast_resource *res)
+{
+ struct hast_resource *tres;
+
+ TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) {
+ if (tres == res) {
+ PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY ||
+ (res->hr_remotein == NULL &&
+ res->hr_remoteout == NULL));
+ continue;
+ }
+ if (tres->hr_remotein != NULL)
+ proto_close(tres->hr_remotein);
+ if (tres->hr_remoteout != NULL)
+ proto_close(tres->hr_remoteout);
+ }
+ if (cfg->hc_controlin != NULL)
+ proto_close(cfg->hc_controlin);
+ proto_close(cfg->hc_controlconn);
+ proto_close(cfg->hc_listenconn);
+ (void)pidfile_close(pfh);
+ hook_fini();
+ pjdlog_fini();
+}
+
static void
child_exit_log(unsigned int pid, int status)
{
Modified: head/sbin/hastd/hastd.h
==============================================================================
--- head/sbin/hastd/hastd.h Fri Jan 28 21:36:01 2011 (r218040)
+++ head/sbin/hastd/hastd.h Fri Jan 28 21:48:15 2011 (r218041)
@@ -43,6 +43,8 @@ extern const char *cfgpath;
extern bool sigexit_received;
extern struct pidfh *pfh;
+void descriptors_cleanup(struct hast_resource *res);
+
void hastd_primary(struct hast_resource *res);
void hastd_secondary(struct hast_resource *res, struct nv *nvin);
More information about the svn-src-all
mailing list