Blame SOURCES/023-recurring-null.patch

ab5585
From 1c534b5a773df5b62aeb8a46842d1e2d4d2266ef Mon Sep 17 00:00:00 2001
ab5585
From: Ken Gaillot <kgaillot@redhat.com>
ab5585
Date: Wed, 1 Mar 2017 15:04:35 -0600
ab5585
Subject: [PATCH] Fix: libservices: ensure recurring actions table is created
ab5585
 before using
ab5585
ab5585
---
ab5585
 lib/services/services.c | 20 ++++++++++++++------
ab5585
 1 file changed, 14 insertions(+), 6 deletions(-)
ab5585
ab5585
diff --git a/lib/services/services.c b/lib/services/services.c
ab5585
index 52d3b55..679f8e7 100644
ab5585
--- a/lib/services/services.c
ab5585
+++ b/lib/services/services.c
ab5585
@@ -90,6 +90,15 @@ resources_find_service_class(const char *agent)
ab5585
     return NULL;
ab5585
 }
ab5585
 
ab5585
+static inline void
ab5585
+init_recurring_actions(void)
ab5585
+{
ab5585
+    if (recurring_actions == NULL) {
ab5585
+        recurring_actions = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
ab5585
+                                                  NULL);
ab5585
+    }
ab5585
+}
ab5585
+
ab5585
 /*!
ab5585
  * \internal
ab5585
  * \brief Check whether op is in-flight systemd or upstart op
ab5585
@@ -513,9 +522,11 @@ services_action_cancel(const char *name, const char *action, int interval)
ab5585
 {
ab5585
     gboolean cancelled = FALSE;
ab5585
     char *id = generate_op_key(name, action, interval);
ab5585
-    svc_action_t *op = g_hash_table_lookup(recurring_actions, id);
ab5585
+    svc_action_t *op = NULL;
ab5585
 
ab5585
     /* We can only cancel a recurring action */
ab5585
+    init_recurring_actions();
ab5585
+    op = g_hash_table_lookup(recurring_actions, id);
ab5585
     if (op == NULL) {
ab5585
         goto done;
ab5585
     }
ab5585
@@ -575,6 +586,7 @@ services_action_kick(const char *name, const char *action, int interval /* ms */
ab5585
     svc_action_t * op = NULL;
ab5585
     char *id = generate_op_key(name, action, interval);
ab5585
 
ab5585
+    init_recurring_actions();
ab5585
     op = g_hash_table_lookup(recurring_actions, id);
ab5585
     free(id);
ab5585
 
ab5585
@@ -604,11 +616,6 @@ handle_duplicate_recurring(svc_action_t * op, void (*action_callback) (svc_actio
ab5585
 {
ab5585
     svc_action_t * dup = NULL;
ab5585
 
ab5585
-    if (recurring_actions == NULL) {
ab5585
-        recurring_actions = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
ab5585
-        return FALSE;
ab5585
-    }
ab5585
-
ab5585
     /* check for duplicates */
ab5585
     dup = g_hash_table_lookup(recurring_actions, op->id);
ab5585
 
ab5585
@@ -700,6 +707,7 @@ services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *
ab5585
     }
ab5585
 
ab5585
     if (op->interval > 0) {
ab5585
+        init_recurring_actions();
ab5585
         if (handle_duplicate_recurring(op, action_callback) == TRUE) {
ab5585
             /* entry rescheduled, dup freed */
ab5585
             /* exit early */
ab5585
-- 
ab5585
1.8.3.1
ab5585