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