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

qdevice: Fix connect heuristics result callback

Qdevice may crash if server disconnect before connect
heuristics callback is processed.

This is quite hard to reproduce without adding sleep before
qdevice_net_heuristics_exec_after_connect call.

Solution is to check if qdevice is still connected and if it doesn't,
just throw away connect heuristics results.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>

(cherry picked from corosync-qdevice project commit
 8dbf1bc8b0f348e468e7c70448705ac92dab68ea)
Jan Friesse 5 лет назад
Родитель
Сommit
b676b06061
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      qdevices/qdevice-net-heuristics.c

+ 7 - 1
qdevices/qdevice-net-heuristics.c

@@ -197,7 +197,6 @@ qdevice_net_connect_heuristics_exec_result_callback(void *heuristics_instance_pt
 	instance = heuristics_instance->qdevice_instance_ptr;
 	net_instance = instance->model_data;
 
-
 	if (qdevice_heuristics_result_notifier_list_set_active(&heuristics_instance->exec_result_notifier_list,
 	    qdevice_net_connect_heuristics_exec_result_callback, 0) != 0) {
 		log(LOG_ERR, "Can't deactivate net connect heuristics exec callback notifier");
@@ -208,6 +207,13 @@ qdevice_net_connect_heuristics_exec_result_callback(void *heuristics_instance_pt
 		return (0);
 	}
 
+	if (net_instance->state != QDEVICE_NET_INSTANCE_STATE_WAITING_VOTEQUORUM_CMAP_EVENTS) {
+		/*
+		 * Not connected to qnetd -> heuristics will be called again on new connect
+		 */
+		return (0);
+	}
+
 	heuristics = qdevice_net_heuristics_exec_result_to_tlv(exec_result);
 
 	send_config_node_list = 1;