Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jan 2012 11:20:42 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r230457 - head/sbin/hastd
Message-ID:  <201201221120.q0MBKgBl073706@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sun Jan 22 11:20:42 2012
New Revision: 230457
URL: http://svn.freebsd.org/changeset/base/230457

Log:
  Free memory that won't be used in child.
  
  MFC after:	1 week

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==============================================================================
--- head/sbin/hastd/hastd.c	Sun Jan 22 11:15:48 2012	(r230456)
+++ head/sbin/hastd/hastd.c	Sun Jan 22 11:20:42 2012	(r230457)
@@ -99,10 +99,10 @@ g_gate_load(void)
 void
 descriptors_cleanup(struct hast_resource *res)
 {
-	struct hast_resource *tres;
+	struct hast_resource *tres, *tmres;
 	struct hastd_listen *lst;
 
-	TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) {
+	TAILQ_FOREACH_SAFE(tres, &cfg->hc_resources, hr_next, tmres) {
 		if (tres == res) {
 			PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY ||
 			    (res->hr_remotein == NULL &&
@@ -119,13 +119,17 @@ descriptors_cleanup(struct hast_resource
 			proto_close(tres->hr_event);
 		if (tres->hr_conn != NULL)
 			proto_close(tres->hr_conn);
+		TAILQ_REMOVE(&cfg->hc_resources, tres, hr_next);
+		free(tres);
 	}
 	if (cfg->hc_controlin != NULL)
 		proto_close(cfg->hc_controlin);
 	proto_close(cfg->hc_controlconn);
-	TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) {
+	while ((lst = TAILQ_FIRST(&cfg->hc_listen)) != NULL) {
+		TAILQ_REMOVE(&cfg->hc_listen, lst, hl_next);
 		if (lst->hl_conn != NULL)
 			proto_close(lst->hl_conn);
+		free(lst);
 	}
 	(void)pidfile_close(pfh);
 	hook_fini();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201221120.q0MBKgBl073706>