Просмотр исходного кода

throw away mode in totempg was operating as a global variable, when it
is possible for different nodes to be in different configurations of
throw away. This patch makes the variable instanced.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2092 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 17 лет назад
Родитель
Сommit
74f6309dcb
1 измененных файлов с 16 добавлено и 11 удалено
  1. 16 11
      exec/totempg.c

+ 16 - 11
exec/totempg.c

@@ -164,11 +164,17 @@ static void (*totempg_log_printf) (int subsys_id, const char *function,
 
 struct totem_config *totempg_totem_config;
 
+enum throw_away_mode {
+	THROW_AWAY_INACTIVE,
+	THROW_AWAY_ACTIVE
+};
+
 struct assembly {
 	unsigned int nodeid;
 	unsigned char data[MESSAGE_SIZE_MAX];
 	int index;
 	unsigned char last_frag_num;
+	enum throw_away_mode throw_away_mode;
 	struct list_head list;
 };
 
@@ -177,13 +183,6 @@ static void assembly_deref (struct assembly *assembly);
 static int callback_token_received_fn (enum totem_callback_token_type type,
 	const void *data);
 
-enum throw_away_mode_t {
-	THROW_AWAY_INACTIVE,
-	THROW_AWAY_ACTIVE
-};
-
-static enum throw_away_mode_t throw_away_mode = THROW_AWAY_INACTIVE;
-
 DECLARE_LIST_INIT(assembly_list_inuse);
 
 DECLARE_LIST_INIT(assembly_list_free);
@@ -274,6 +273,9 @@ static struct assembly *assembly_ref (unsigned int nodeid)
 		list_del (&assembly->list);
 		list_add (&assembly->list, &assembly_list_inuse);
 		assembly->nodeid = nodeid;
+		assembly->index = 0;
+		assembly->last_frag_num = 0;
+		assembly->throw_away_mode = THROW_AWAY_INACTIVE;
 		return (assembly);
 	}
 
@@ -287,6 +289,9 @@ static struct assembly *assembly_ref (unsigned int nodeid)
 	 */
 	assert (assembly);
 	assembly->nodeid = nodeid;
+	assembly->index = 0;
+	assembly->last_frag_num = 0;
+	assembly->throw_away_mode = THROW_AWAY_INACTIVE;
 	list_init (&assembly->list);
 	list_add (&assembly->list, &assembly_list_inuse);
 
@@ -597,10 +602,10 @@ static void totempg_deliver_fn (
 	 */
 	start = 0;
 
-	if (throw_away_mode == THROW_AWAY_ACTIVE) {
+	if (assembly->throw_away_mode == THROW_AWAY_ACTIVE) {
 		 /* Throw away the first msg block */
 		if (mcast->fragmented == 0 || mcast->fragmented == 1) {
-			throw_away_mode = THROW_AWAY_INACTIVE;
+			assembly->throw_away_mode = THROW_AWAY_INACTIVE;
 
 			assembly->index += msg_lens[0];
 			iov_delv.iov_base = &assembly->data[assembly->index];
@@ -608,7 +613,7 @@ static void totempg_deliver_fn (
 			start = 1;
 		}
 	} else 
-	if (throw_away_mode == THROW_AWAY_INACTIVE) {
+	if (assembly->throw_away_mode == THROW_AWAY_INACTIVE) {
 		if (continuation == assembly->last_frag_num) {
 			assembly->last_frag_num = mcast->fragmented;
 			for  (i = start; i < msg_count; i++) {
@@ -621,7 +626,7 @@ static void totempg_deliver_fn (
 				}
 			}
 		} else {
-			throw_away_mode = THROW_AWAY_ACTIVE;
+			assembly->throw_away_mode = THROW_AWAY_ACTIVE;
 		}
 	}