Blame SOURCES/bz720543-pcmk-fencing_deep_copy_current_topology_level_list_on_remote_op.patch

ed0026
commit 5cc40550ed6f385eb25042b1ab14339a760de1e8
ed0026
Author: David Vossel <dvossel@redhat.com>
ed0026
Date:   Thu Oct 17 20:34:48 2013 -0500
ed0026
ed0026
    Fix: fencing: Deep copy current topology level list on remote op
ed0026
    
ed0026
    (cherry picked from commit ef29a502e0e0506fd52fc60e51e06ffd6c375f4a)
ed0026
ed0026
diff --git a/fencing/internal.h b/fencing/internal.h
ed0026
index 11a8c58..da510c3 100644
ed0026
--- a/fencing/internal.h
ed0026
+++ b/fencing/internal.h
ed0026
@@ -105,6 +105,8 @@ typedef struct remote_fencing_op_s {
ed0026
     /*! The current topology level being executed */
ed0026
     guint level;
ed0026
     /*! The device list of all the devices at the current executing topology level. */
ed0026
+    GListPtr devices_list;
ed0026
+    /*! Current entry in the topology device list */
ed0026
     GListPtr devices;
ed0026
 
ed0026
     /*! List of duplicate operations attached to this operation. Once this operation
ed0026
diff --git a/fencing/remote.c b/fencing/remote.c
ed0026
index af4fb9e..8c8df6d 100644
ed0026
--- a/fencing/remote.c
ed0026
+++ b/fencing/remote.c
ed0026
@@ -124,6 +124,10 @@ free_remote_op(gpointer data)
ed0026
         free_xml(op->request);
ed0026
         op->request = NULL;
ed0026
     }
ed0026
+    if (op->devices_list) {
ed0026
+        g_list_free_full(op->devices_list, free);
ed0026
+        op->devices_list = NULL;
ed0026
+    }
ed0026
     free(op);
ed0026
 }
ed0026
 
ed0026
@@ -391,6 +395,22 @@ topology_is_empty(stonith_topology_t *tp)
ed0026
     return TRUE;
ed0026
 }
ed0026
 
ed0026
+/* deep copy the device list */
ed0026
+static void
ed0026
+set_op_device_list(remote_fencing_op_t * op, GListPtr devices)
ed0026
+{
ed0026
+    GListPtr lpc = NULL;
ed0026
+
ed0026
+    if (op->devices_list) {
ed0026
+        g_list_free_full(op->devices_list, free);
ed0026
+        op->devices_list = NULL;
ed0026
+    }
ed0026
+    for (lpc = devices; lpc != NULL; lpc = lpc->next) {
ed0026
+        op->devices_list = g_list_append(op->devices_list, strdup(lpc->data));
ed0026
+    }
ed0026
+    op->devices = op->devices_list;
ed0026
+}
ed0026
+
ed0026
 static int
ed0026
 stonith_topology_next(remote_fencing_op_t * op)
ed0026
 {
ed0026
@@ -415,7 +435,7 @@ stonith_topology_next(remote_fencing_op_t * op)
ed0026
         crm_trace("Attempting fencing level %d for %s (%d devices) - %s@%s.%.8s",
ed0026
                   op->level, op->target, g_list_length(tp->levels[op->level]),
ed0026
                   op->client_name, op->originator, op->id);
ed0026
-        op->devices = tp->levels[op->level];
ed0026
+        set_op_device_list(op, tp->levels[op->level]);
ed0026
         return pcmk_ok;
ed0026
     }
ed0026