[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] Make rgmanager flip rg states when storing.



Patch is against head.  This might break upgrade compatibility.  A more
robust patch including endian detection will be required for -RHEL5

-- Lon

Index: rg_state.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/rg_state.c,v
retrieving revision 1.43
diff -u -p -r1.43 rg_state.c
--- rg_state.c	14 Dec 2007 19:37:00 -0000	1.43
+++ rg_state.c	2 Jan 2008 19:12:22 -0000
@@ -271,6 +271,7 @@ int
 set_rg_state(char *name, rg_state_t *svcblk)
 {
 	char res[256];
+	rg_state_t svcblk_store;
 #ifndef OPENAIS
 	cluster_member_list_t *membership;
 	int ret, tries = 0;
@@ -280,8 +281,12 @@ set_rg_state(char *name, rg_state_t *svc
 		strncpy(svcblk->rs_name, name, sizeof(svcblk->rs_name));
 
 	snprintf(res, sizeof(res), "rg=\"%s\"", name);
+
+	memcpy(&svcblk_store, svcblk, sizeof(svcblk));
+	swab_rg_state_t(&svcblk_store);
+
 #ifdef OPENAIS
-	if (ds_write(res, svcblk, sizeof(*svcblk)) < 0)
+	if (ds_write(res, &svcblk_store, sizeof(svcblk_store)) < 0)
 		return -1;
 	return 0;
 #else
@@ -289,8 +294,9 @@ set_rg_state(char *name, rg_state_t *svc
 		/* Retry up to 3 times just in case members transition
 		   while we're trying to commit something */
 		membership = member_list();
-		ret = vf_write(membership, VFF_IGN_CONN_ERRORS, res, svcblk,
-       		       	       sizeof(*svcblk));
+		ret = vf_write(membership, VFF_IGN_CONN_ERRORS, res,
+			       &svcblk_store,
+       		       	       sizeof(svcblk_store));
 		free_member_list(membership);
 	} while (ret == VFR_TIMEOUT && ++tries < 3);
 
@@ -361,6 +367,7 @@ get_rg_state(char *name, rg_state_t *svc
 	}
 
 	memcpy(svcblk, data, sizeof(*svcblk));
+	swab_rg_state_t(svcblk);
 
 	return 0;
 #else
@@ -400,6 +407,7 @@ get_rg_state(char *name, rg_state_t *svc
 
 	/* Copy out the data. */
 	memcpy(svcblk, data, sizeof(*svcblk));
+	swab_rg_state_t(svcblk);
 	free(data);
 	free_member_list(membership);
 
@@ -453,6 +461,7 @@ get_rg_state_local(char *name, rg_state_
 
 	/* Copy out the data. */
 	memcpy(svcblk, data, sizeof(*svcblk));
+	swab_rg_state_t(svcblk);
 #ifndef OPENAIS
 	free(data);
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]