File pacemaker-contoller-scheduler-guard-hash-table-deletes.patch of Package pacemaker.21299

commit 0e47782108626dbc9899c88410eeaba16881a7af
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Wed May 2 20:27:42 2018 -0500

    Low: contoller,scheduler: guard hash table deletes
    
    In particular, it is possible for the controller to exit and call
    throttle_fini() before throttle_init() had a chance to be called. Without a
    guard, g_hash_table_destroy() would log an (otherwise harmless) assertion.

Index: pacemaker-1.1.18+20180430.b12c320f5/crmd/throttle.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/crmd/throttle.c
+++ pacemaker-1.1.18+20180430.b12c320f5/crmd/throttle.c
@@ -424,8 +424,14 @@ throttle_init(void)
 void
 throttle_fini(void)
 {
-    mainloop_timer_del(throttle_timer); throttle_timer = NULL;
-    g_hash_table_destroy(throttle_records); throttle_records = NULL;
+    if (throttle_timer != NULL) {
+        mainloop_timer_del(throttle_timer);
+        throttle_timer = NULL;
+    }
+    if (throttle_records != NULL) {
+        g_hash_table_destroy(throttle_records);
+        throttle_records = NULL;
+    }
 }
 
 int
Index: pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/container.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/lib/pengine/container.c
+++ pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/container.c
@@ -612,7 +612,9 @@ create_remote_resource(
         tuple->node->rsc_discover_mode = pe_discover_exclusive;
 
         /* Ensure the node shows up as allowed and with the correct discovery set */
-        g_hash_table_destroy(tuple->child->allowed_nodes);
+        if (tuple->child->allowed_nodes != NULL) {
+            g_hash_table_destroy(tuple->child->allowed_nodes);
+        }
         tuple->child->allowed_nodes = g_hash_table_new_full(crm_str_hash,
                                                             g_str_equal, NULL,
                                                             free);
Index: pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/native.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/lib/pengine/native.c
+++ pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/native.c
@@ -66,7 +66,9 @@ native_add_running(resource_t * rsc, nod
                     node_t *local_node = NULL;
 
                     /* make sure it doesn't come up again */
-                    g_hash_table_destroy(rsc->allowed_nodes);
+                    if (rsc->allowed_nodes != NULL) {
+                        g_hash_table_destroy(rsc->allowed_nodes);
+                    }
                     rsc->allowed_nodes = node_hash_from_list(data_set->nodes);
                     g_hash_table_iter_init(&gIter, rsc->allowed_nodes);
                     while (g_hash_table_iter_next(&gIter, NULL, (void **)&local_node)) {
Index: pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/unpack.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/lib/pengine/unpack.c
+++ pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/unpack.c
@@ -2591,7 +2591,9 @@ unpack_rsc_op_failure(resource_t * rsc,
         }
         crm_warn("Making sure %s doesn't come up again", fail_rsc->id);
         /* make sure it doesn't come up again */
-        g_hash_table_destroy(fail_rsc->allowed_nodes);
+        if (fail_rsc->allowed_nodes != NULL) {
+            g_hash_table_destroy(fail_rsc->allowed_nodes);
+        }
         fail_rsc->allowed_nodes = node_hash_from_list(data_set->nodes);
         g_hash_table_foreach(fail_rsc->allowed_nodes, set_node_score, &score);
     }
openSUSE Build Service is sponsored by