]> git.proxmox.com Git - mirror_corosync-qdevice.git/commitdiff
qdevice: Fix connect heuristics result callback
authorJan Friesse <jfriesse@redhat.com>
Wed, 12 Aug 2020 13:42:12 +0000 (15:42 +0200)
committerJan Friesse <jfriesse@redhat.com>
Wed, 12 Aug 2020 13:52:18 +0000 (15:52 +0200)
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>
qdevices/qdevice-net-heuristics.c

index 0f39e992a29281d436901757b535ad675e3419ce..f95e118fb487ba20841e8014ce857f3ffe50a01e 100644 (file)
@@ -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;