Skip to contentSkip to conversation

rgmanager: Fix referencing bug

PATCH New Lon Hohberger 1 participant 1 message Aug 21, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rgmanager: Fix referencing bug

If you placed a resource in the <resources> block and it did not have a primary="1" attribute in the resource agent metadata, rgmanager would ignore it in the resource tree when you tried to address it using the ref="" keyword.

---
 rgmanager/src/daemons/reslist.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
rgmanager/src/daemons/reslist.c +8 -5
index fac4812..7a2d69a 100644
@@ -257,7 +257,8 @@ resource_t *
 find_resource_by_ref(resource_t **reslist, const char *type, const char *ref)
 {
 	resource_t *curr;
-	int x;
+	resource_t *first_possible = NULL;
+	int x, flags = RA_UNIQUE|RA_REQUIRED;
 
 	list_do(reslist, curr) {
 		if (strcmp(curr->r_rule->rr_type, type))
@@ -269,16 +270,18 @@ find_resource_by_ref(resource_t **reslist, const char *type, const char *ref)
 		 */
 		for (x = 0; curr->r_attrs && curr->r_attrs[x].ra_name;
 		     x++) {
-			if (!(curr->r_attrs[x].ra_flags & RA_PRIMARY))
-				continue;
 			if (strcmp(ref, curr->r_attrs[x].ra_value))
 				continue;
-
+			if (((curr->r_attrs[x].ra_flags & flags) == flags) &&
+		    	    !first_possible)
+				first_possible = curr;
+			if (!(curr->r_attrs[x].ra_flags & RA_PRIMARY))
+				continue;
 			return curr;
 		}
 	} while (!list_done(reslist, curr));
 
-	return NULL;
+	return first_possible;
 }
 
 
Signature · 1 line
1.6.2.5