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

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



On Wed, 2008-01-02 at 14:14 -0500, Lon Hohberger wrote:
> Patch is against head.  This might break upgrade compatibility.  A more
> robust patch including endian detection will be required for -RHEL5

This one was memcpy()ing the wrong size.  Here's a new one.

-- Lon


Index: rg_state.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/rg_state.c,v
retrieving revision 1.44
diff -u -p -r1.44 rg_state.c
--- rg_state.c	30 Dec 2007 08:27:21 -0000	1.44
+++ rg_state.c	2 Jan 2008 19:30:49 -0000
@@ -270,6 +270,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;
@@ -279,8 +280,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_store));
+	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
@@ -288,8 +293,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);
 
@@ -360,6 +366,7 @@ get_rg_state(char *name, rg_state_t *svc
 	}
 
 	memcpy(svcblk, data, sizeof(*svcblk));
+	swab_rg_state_t(svcblk);
 
 	return 0;
 #else
@@ -399,6 +406,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);
 
@@ -452,6 +460,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]