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

totem: Fix debug warnings printed by knet

Fix crash introduced a couple of commits ago in iface_get

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 8 лет назад
Родитель
Сommit
111bfbc11d
2 измененных файлов с 30 добавлено и 8 удалено
  1. 29 7
      exec/totemknet.c
  2. 1 1
      exec/totemsrp.c

+ 29 - 7
exec/totemknet.c

@@ -1140,10 +1140,15 @@ int totemknet_member_add (
 	struct sockaddr_storage remote_ss;
 	struct sockaddr_storage local_ss;
 	int addrlen;
+	int i;
+	int host_found = 0;
+	knet_node_id_t host_ids[KNET_MAX_HOST];
+	size_t num_host_ids;
 
-	/* Only create 1 loopback link */
-	// NOTE: THis depends on member_remove being run before member_add when reeconfiguring
-	// otherwise we could be left with no loopback.
+	/* Only create 1 loopback link.
+	 * NOTE: THis depends on member_remove being run before member_add when reconfiguring
+	 * otherwise we could be left with no loopback.
+	 */
 	if (member->nodeid == instance->our_nodeid && instance->loopback_link > -1) {
 		return 0;
 	}
@@ -1151,12 +1156,29 @@ int totemknet_member_add (
 	knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_add: %d (%s), link=%d", member->nodeid, totemip_print(member), link_no);
 	knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet:      local: %d (%s)", local->nodeid, totemip_print(local));
 
-	// TODO FIXME - prints errors when host already exists
-	err = knet_host_add(instance->knet_handle, member->nodeid);
-	if (err != 0 && errno != EEXIST) {
-		KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_host_add");
+
+	/* Only add the host if it doesn't already exist in knet */
+	err = knet_host_get_host_list(instance->knet_handle, host_ids, &num_host_ids);
+	if (err) {
+		KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_host_get_host_list");
 		return -1;
 	}
+	for (i=0; i<num_host_ids; i++) {
+		if (host_ids[i] == member->nodeid) {
+			host_found = 1;
+		}
+	}
+
+	if (!host_found) {
+		err = knet_host_add(instance->knet_handle, member->nodeid);
+		if (err != 0 && errno != EEXIST) {
+			KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_host_add");
+			return -1;
+		}
+	} else {
+		knet_log_printf (LOGSYS_LEVEL_DEBUG, "nodeid %d already added", member->nodeid);
+	}
+
 
 	if (err == 0) {
 		if (knet_host_set_policy(instance->knet_handle, member->nodeid, instance->link_mode)) {

+ 1 - 1
exec/totemsrp.c

@@ -1052,7 +1052,7 @@ int totemsrp_ifaces_get (
 			if (instance->totem_config->interfaces[i].configured &&
 			    instance->totem_config->interfaces[i].member_list[n].nodeid == nodeid) {
 				memcpy(iface_ptr, &instance->totem_config->interfaces[i].member_list[n], sizeof(struct totem_ip_address));
-				iface_ptr += sizeof(struct totem_ip_address);
+				iface_ptr++;
 				if (++num_ifs > interfaces_size) {
 					res = -2;
 					break;