From 91c557cf2b28be0b91758536bf37bdf6fe2b4e38 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Jun 10 2020 17:56:11 +0000 Subject: Refactor: controller: convert active_op_t booleans to bitmask --- diff --git a/daemons/controld/controld_execd.c b/daemons/controld/controld_execd.c index 4e3a29b..36acf7a 100644 --- a/daemons/controld/controld_execd.c +++ b/daemons/controld/controld_execd.c @@ -1150,18 +1150,17 @@ cancel_op(lrm_state_t * lrm_state, const char *rsc_id, const char *key, int op, pending = g_hash_table_lookup(lrm_state->pending_ops, key); if (pending) { - if (remove && pending->remove == FALSE) { - pending->remove = TRUE; + if (remove && is_not_set(pending->flags, active_op_remove)) { + set_bit(pending->flags, active_op_remove); crm_debug("Scheduling %s for removal", key); } - if (pending->cancelled) { + if (is_set(pending->flags, active_op_cancelled)) { crm_debug("Operation %s already cancelled", key); free(local_key); return FALSE; } - - pending->cancelled = TRUE; + set_bit(pending->flags, active_op_cancelled); } else { crm_info("No pending op found for %s", key); @@ -2654,7 +2653,7 @@ process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op, crm_err("Recurring operation %s was cancelled without transition information", op_key); - } else if (pending->remove) { + } else if (is_set(pending->flags, active_op_remove)) { /* This recurring operation was cancelled (by us) and pending, and we * have been waiting for it to finish. */ diff --git a/daemons/controld/controld_lrm.h b/daemons/controld/controld_lrm.h index 27df5d7..3ab7048 100644 --- a/daemons/controld/controld_lrm.h +++ b/daemons/controld/controld_lrm.h @@ -33,12 +33,16 @@ typedef struct resource_history_s { void history_free(gpointer data); +enum active_op_e { + active_op_remove = (1 << 0), + active_op_cancelled = (1 << 1), +}; + // In-flight action (recurring or pending) typedef struct active_op_s { guint interval_ms; int call_id; - gboolean remove; - gboolean cancelled; + uint32_t flags; // bitmask of active_op_e time_t start_time; char *rsc_id; char *op_type;