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

rrp: Handle endless loop if all ifaces are faulty

If all interfaces were faulty, passive_mcast_flush_send and related
functions ended in endless loop. This is now handled and if there is no
live interface, message is dropped.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed by: Steven Dake <sdake@redhat.com>
Jan Friesse 14 лет назад
Родитель
Сommit
0eade8de79
1 измененных файлов с 20 добавлено и 9 удалено
  1. 20 9
      exec/totemrrp.c

+ 20 - 9
exec/totemrrp.c

@@ -1018,12 +1018,16 @@ static void passive_mcast_flush_send (
 	unsigned int msg_len)
 {
 	struct passive_instance *passive_instance = (struct passive_instance *)instance->rrp_algo_instance;
+	int i = 0;
 
 	do {
 		passive_instance->msg_xmit_iface = (passive_instance->msg_xmit_iface + 1) % instance->interface_count;
-	} while (passive_instance->faulty[passive_instance->msg_xmit_iface] == 1);
+		i++;
+	} while ((i <= instance->interface_count) && (passive_instance->faulty[passive_instance->msg_xmit_iface] == 1));
 
-	totemnet_mcast_flush_send (instance->net_handles[passive_instance->msg_xmit_iface], msg, msg_len);
+	if (i <= instance->interface_count) {
+		totemnet_mcast_flush_send (instance->net_handles[passive_instance->msg_xmit_iface], msg, msg_len);
+	}
 }
 
 static void passive_mcast_noflush_send (
@@ -1032,13 +1036,16 @@ static void passive_mcast_noflush_send (
 	unsigned int msg_len)
 {
 	struct passive_instance *passive_instance = (struct passive_instance *)instance->rrp_algo_instance;
+	int i = 0;
 
 	do {
 		passive_instance->msg_xmit_iface = (passive_instance->msg_xmit_iface + 1) % instance->interface_count;
-	} while (passive_instance->faulty[passive_instance->msg_xmit_iface] == 1);
-
+		i++;
+	} while ((i <= instance->interface_count) && (passive_instance->faulty[passive_instance->msg_xmit_iface] == 1));
 
-	totemnet_mcast_noflush_send (instance->net_handles[passive_instance->msg_xmit_iface], msg, msg_len);
+	if (i <= instance->interface_count) {
+		totemnet_mcast_noflush_send (instance->net_handles[passive_instance->msg_xmit_iface], msg, msg_len);
+	}
 }
 
 static void passive_token_recv (
@@ -1073,14 +1080,18 @@ static void passive_token_send (
 	unsigned int msg_len)
 {
 	struct passive_instance *passive_instance = (struct passive_instance *)instance->rrp_algo_instance;
+	int i = 0;
 
 	do {
 		passive_instance->token_xmit_iface = (passive_instance->token_xmit_iface + 1) % instance->interface_count;
-	} while (passive_instance->faulty[passive_instance->token_xmit_iface] == 1);
+		i++;
+	} while ((i <= instance->interface_count) && (passive_instance->faulty[passive_instance->token_xmit_iface] == 1));
 
-	totemnet_token_send (
-		instance->net_handles[passive_instance->token_xmit_iface],
-		msg, msg_len);
+	if (i <= instance->interface_count) {
+		totemnet_token_send (
+		    instance->net_handles[passive_instance->token_xmit_iface],
+		    msg, msg_len);
+	}
 
 }