From 3bf6d03672bc0f686ea2a21f3e3aac55f114c139 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 26 Aug 2010 16:22:03 +0000
Subject: [PATCH] fix for creating an association's usage before using it

---
 src/common/assoc_mgr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/common/assoc_mgr.c b/src/common/assoc_mgr.c
index 7e9e1f26ba7..7d47baface0 100644
--- a/src/common/assoc_mgr.c
+++ b/src/common/assoc_mgr.c
@@ -288,6 +288,9 @@ static int _set_assoc_parent_and_user(slurmdb_association_rec_t *assoc,
 		return SLURM_ERROR;
 	}
 
+	if(!assoc->usage)
+		assoc->usage = create_assoc_mgr_association_usage();
+
 	if(assoc->parent_id) {
 		/* To speed things up we are first looking if we have
 		   a parent_id to look for.  If that doesn't work see
@@ -318,6 +321,9 @@ static int _set_assoc_parent_and_user(slurmdb_association_rec_t *assoc,
 			list_iterator_destroy(itr);
 		}
 		if(assoc->usage->parent_assoc_ptr && setup_childern) {
+			if(!assoc->usage->parent_assoc_ptr->usage)
+				assoc->usage->parent_assoc_ptr->usage =
+					create_assoc_mgr_association_usage();
 			if(!assoc->usage->
 			   parent_assoc_ptr->usage->childern_list)
 				assoc->usage->
@@ -403,8 +409,6 @@ static int _post_association_list(List assoc_list)
 
 	//START_TIMER;
 	while((assoc = list_next(itr))) {
-		if(!assoc->usage)
-			assoc->usage = create_assoc_mgr_association_usage();
 		_set_assoc_parent_and_user(assoc, assoc_list, reset);
 		reset = 0;
 	}
-- 
GitLab