|
|
60de42 |
From ef711f968ba143b12fb0654b6d75045a04f83d37 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Thu, 9 Feb 2017 22:30:17 +0100
|
|
|
60de42 |
Subject: [PATCH 1/6] Refactor: lib/services: unify/add include guards for *.h
|
|
|
60de42 |
|
|
|
60de42 |
(wild guess has it that MH stood for long-dead Matahari project)
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/pcmk-dbus.h | 8 ++++----
|
|
|
60de42 |
lib/services/services_private.h | 6 +++---
|
|
|
60de42 |
lib/services/systemd.h | 5 +++++
|
|
|
60de42 |
lib/services/upstart.h | 7 +++----
|
|
|
60de42 |
4 files changed, 15 insertions(+), 11 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/pcmk-dbus.h b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
index c575dda..31bcf0e 100644
|
|
|
60de42 |
--- a/lib/services/pcmk-dbus.h
|
|
|
60de42 |
+++ b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
@@ -8,9 +8,9 @@
|
|
|
60de42 |
#ifndef PCMK_DBUS__H
|
|
|
60de42 |
# define PCMK_DBUS__H
|
|
|
60de42 |
|
|
|
60de42 |
-#ifndef DBUS_TIMEOUT_USE_DEFAULT
|
|
|
60de42 |
-# define DBUS_TIMEOUT_USE_DEFAULT -1
|
|
|
60de42 |
-#endif
|
|
|
60de42 |
+# ifndef DBUS_TIMEOUT_USE_DEFAULT
|
|
|
60de42 |
+# define DBUS_TIMEOUT_USE_DEFAULT -1
|
|
|
60de42 |
+# endif
|
|
|
60de42 |
|
|
|
60de42 |
DBusConnection *pcmk_dbus_connect(void);
|
|
|
60de42 |
void pcmk_dbus_connection_setup_with_select(DBusConnection *c);
|
|
|
60de42 |
@@ -28,4 +28,4 @@ char *pcmk_dbus_get_property(
|
|
|
60de42 |
bool pcmk_dbus_find_error(DBusPendingCall *pending, DBusMessage *reply,
|
|
|
60de42 |
DBusError *error);
|
|
|
60de42 |
|
|
|
60de42 |
-#endif /* PCMK_DBUS__H */
|
|
|
60de42 |
+#endif /* PCMK_DBUS__H */
|
|
|
60de42 |
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
|
|
|
60de42 |
index 43aedc6..0e12d18 100644
|
|
|
60de42 |
--- a/lib/services/services_private.h
|
|
|
60de42 |
+++ b/lib/services/services_private.h
|
|
|
60de42 |
@@ -16,8 +16,8 @@
|
|
|
60de42 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
60de42 |
*/
|
|
|
60de42 |
|
|
|
60de42 |
-#ifndef __MH_SERVICES_PRIVATE_H__
|
|
|
60de42 |
-# define __MH_SERVICES_PRIVATE_H__
|
|
|
60de42 |
+#ifndef SERVICES_PRIVATE__H
|
|
|
60de42 |
+# define SERVICES_PRIVATE__H
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_DBUS
|
|
|
60de42 |
# include <dbus/dbus.h>
|
|
|
60de42 |
@@ -69,4 +69,4 @@ gboolean is_op_blocked(const char *rsc);
|
|
|
60de42 |
void services_set_op_pending(svc_action_t *op, DBusPendingCall *pending);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
-#endif /* __MH_SERVICES_PRIVATE_H__ */
|
|
|
60de42 |
+#endif /* SERVICES_PRIVATE__H */
|
|
|
60de42 |
diff --git a/lib/services/systemd.h b/lib/services/systemd.h
|
|
|
60de42 |
index acd832e..17e654e 100644
|
|
|
60de42 |
--- a/lib/services/systemd.h
|
|
|
60de42 |
+++ b/lib/services/systemd.h
|
|
|
60de42 |
@@ -16,8 +16,13 @@
|
|
|
60de42 |
* Copyright (C) 2012 Andrew Beekhof <andrew@beekhof.net>
|
|
|
60de42 |
*/
|
|
|
60de42 |
|
|
|
60de42 |
+#ifndef SYSTEMD__H
|
|
|
60de42 |
+# define SYSTEMD__H
|
|
|
60de42 |
+
|
|
|
60de42 |
G_GNUC_INTERNAL GList *systemd_unit_listall(void);
|
|
|
60de42 |
G_GNUC_INTERNAL int systemd_unit_exec(svc_action_t * op);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean systemd_unit_exists(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean systemd_unit_running(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL void systemd_cleanup(void);
|
|
|
60de42 |
+
|
|
|
60de42 |
+#endif /* SYSTEMD__H */
|
|
|
60de42 |
diff --git a/lib/services/upstart.h b/lib/services/upstart.h
|
|
|
60de42 |
index a837226..523d208 100644
|
|
|
60de42 |
--- a/lib/services/upstart.h
|
|
|
60de42 |
+++ b/lib/services/upstart.h
|
|
|
60de42 |
@@ -13,12 +13,11 @@
|
|
|
60de42 |
* License along with this library; if not, write to the Free Software
|
|
|
60de42 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
60de42 |
*
|
|
|
60de42 |
- * File: upstart-dbus.c
|
|
|
60de42 |
* Copyright (C) 2010 Senko Rasic <senko.rasic@dobarkod.hr>
|
|
|
60de42 |
* Copyright (c) 2010 Ante Karamatic <ivoks@init.hr>
|
|
|
60de42 |
*/
|
|
|
60de42 |
-#ifndef _UPSTART_DBUS_H_
|
|
|
60de42 |
-# define _UPSTART_DBUS_H_
|
|
|
60de42 |
+#ifndef UPSTART__H
|
|
|
60de42 |
+# define UPSTART__H
|
|
|
60de42 |
|
|
|
60de42 |
# include <glib.h>
|
|
|
60de42 |
# include "crm/services.h"
|
|
|
60de42 |
@@ -29,4 +28,4 @@ G_GNUC_INTERNAL gboolean upstart_job_exists(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean upstart_job_running(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL void upstart_cleanup(void);
|
|
|
60de42 |
|
|
|
60de42 |
-#endif /* _UPSTART_DBUS_H_ */
|
|
|
60de42 |
+#endif /* UPSTART__H */
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 5dc4937b9588b3fb1d4297eedd7c433aafd8cc81 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Thu, 9 Feb 2017 22:40:39 +0100
|
|
|
60de42 |
Subject: [PATCH 2/6] Refactor: lib/services: make *.h self-sufficient wrt.
|
|
|
60de42 |
other includes
|
|
|
60de42 |
|
|
|
60de42 |
Also make function declaration follow the actual definitions.
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/pcmk-dbus.h | 2 ++
|
|
|
60de42 |
lib/services/services_private.h | 3 +++
|
|
|
60de42 |
lib/services/systemd.h | 5 ++++-
|
|
|
60de42 |
lib/services/upstart.h | 2 +-
|
|
|
60de42 |
4 files changed, 10 insertions(+), 2 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/pcmk-dbus.h b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
index 31bcf0e..e071349 100644
|
|
|
60de42 |
--- a/lib/services/pcmk-dbus.h
|
|
|
60de42 |
+++ b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
@@ -8,6 +8,8 @@
|
|
|
60de42 |
#ifndef PCMK_DBUS__H
|
|
|
60de42 |
# define PCMK_DBUS__H
|
|
|
60de42 |
|
|
|
60de42 |
+# include <dbus/dbus.h>
|
|
|
60de42 |
+
|
|
|
60de42 |
# ifndef DBUS_TIMEOUT_USE_DEFAULT
|
|
|
60de42 |
# define DBUS_TIMEOUT_USE_DEFAULT -1
|
|
|
60de42 |
# endif
|
|
|
60de42 |
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
|
|
|
60de42 |
index 0e12d18..60b1b14 100644
|
|
|
60de42 |
--- a/lib/services/services_private.h
|
|
|
60de42 |
+++ b/lib/services/services_private.h
|
|
|
60de42 |
@@ -19,6 +19,9 @@
|
|
|
60de42 |
#ifndef SERVICES_PRIVATE__H
|
|
|
60de42 |
# define SERVICES_PRIVATE__H
|
|
|
60de42 |
|
|
|
60de42 |
+# include <glib.h>
|
|
|
60de42 |
+# include "crm/services.h"
|
|
|
60de42 |
+
|
|
|
60de42 |
#if SUPPORT_DBUS
|
|
|
60de42 |
# include <dbus/dbus.h>
|
|
|
60de42 |
#endif
|
|
|
60de42 |
diff --git a/lib/services/systemd.h b/lib/services/systemd.h
|
|
|
60de42 |
index 17e654e..98150dd 100644
|
|
|
60de42 |
--- a/lib/services/systemd.h
|
|
|
60de42 |
+++ b/lib/services/systemd.h
|
|
|
60de42 |
@@ -19,8 +19,11 @@
|
|
|
60de42 |
#ifndef SYSTEMD__H
|
|
|
60de42 |
# define SYSTEMD__H
|
|
|
60de42 |
|
|
|
60de42 |
+# include <glib.h>
|
|
|
60de42 |
+# include "crm/services.h"
|
|
|
60de42 |
+
|
|
|
60de42 |
G_GNUC_INTERNAL GList *systemd_unit_listall(void);
|
|
|
60de42 |
-G_GNUC_INTERNAL int systemd_unit_exec(svc_action_t * op);
|
|
|
60de42 |
+G_GNUC_INTERNAL gboolean systemd_unit_exec(svc_action_t * op);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean systemd_unit_exists(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean systemd_unit_running(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL void systemd_cleanup(void);
|
|
|
60de42 |
diff --git a/lib/services/upstart.h b/lib/services/upstart.h
|
|
|
60de42 |
index 523d208..8d41c11 100644
|
|
|
60de42 |
--- a/lib/services/upstart.h
|
|
|
60de42 |
+++ b/lib/services/upstart.h
|
|
|
60de42 |
@@ -23,7 +23,7 @@
|
|
|
60de42 |
# include "crm/services.h"
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL GList *upstart_job_listall(void);
|
|
|
60de42 |
-G_GNUC_INTERNAL int upstart_job_exec(svc_action_t * op, gboolean synchronous);
|
|
|
60de42 |
+G_GNUC_INTERNAL gboolean upstart_job_exec(svc_action_t * op, gboolean synchronous);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean upstart_job_exists(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean upstart_job_running(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL void upstart_cleanup(void);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 6b12e0d1284cac96e66780aa4aeb7c32619089fc Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Thu, 9 Feb 2017 22:46:42 +0100
|
|
|
60de42 |
Subject: [PATCH 3/6] Refactor: lib/services: ensure *.h declare externally
|
|
|
60de42 |
hidden functions
|
|
|
60de42 |
|
|
|
60de42 |
...following the precedent of {upstart,systemd}.h. Note also that
|
|
|
60de42 |
since hardening-related commit 658fff944 [$LD -z now], it's even more
|
|
|
60de42 |
desirable to limit "symbol smog" as much as possible and symbols only
|
|
|
60de42 |
used within the library like these are trivially expendable (assuming
|
|
|
60de42 |
suitable toolchain).
|
|
|
60de42 |
|
|
|
60de42 |
As we use G_GNU_C_INTERNAL macro from glib2, we should care to require
|
|
|
60de42 |
at least that version that introduced it, i.e., 2.6 per documentation.
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/pcmk-dbus.h | 13 +++++++++++++
|
|
|
60de42 |
lib/services/services_private.h | 14 ++++++++++++++
|
|
|
60de42 |
pacemaker.spec.in | 4 +++-
|
|
|
60de42 |
3 files changed, 30 insertions(+), 1 deletion(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/pcmk-dbus.h b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
index e071349..3f3547e 100644
|
|
|
60de42 |
--- a/lib/services/pcmk-dbus.h
|
|
|
60de42 |
+++ b/lib/services/pcmk-dbus.h
|
|
|
60de42 |
@@ -14,19 +14,32 @@
|
|
|
60de42 |
# define DBUS_TIMEOUT_USE_DEFAULT -1
|
|
|
60de42 |
# endif
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
DBusConnection *pcmk_dbus_connect(void);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
void pcmk_dbus_connection_setup_with_select(DBusConnection *c);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
void pcmk_dbus_disconnect(DBusConnection *connection);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
DBusPendingCall *pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection,
|
|
|
60de42 |
void(*done)(DBusPendingCall *pending, void *user_data), void *user_data, int timeout);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
DBusMessage *pcmk_dbus_send_recv(DBusMessage *msg, DBusConnection *connection, DBusError *error, int timeout);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
bool pcmk_dbus_type_check(DBusMessage *msg, DBusMessageIter *field, int expected, const char *function, int line);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
char *pcmk_dbus_get_property(
|
|
|
60de42 |
DBusConnection *connection, const char *target, const char *obj, const gchar * iface, const char *name,
|
|
|
60de42 |
void (*callback)(const char *name, const char *value, void *userdata), void *userdata,
|
|
|
60de42 |
DBusPendingCall **pending, int timeout);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
bool pcmk_dbus_find_error(DBusPendingCall *pending, DBusMessage *reply,
|
|
|
60de42 |
DBusError *error);
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
|
|
|
60de42 |
index 60b1b14..41895a9 100644
|
|
|
60de42 |
--- a/lib/services/services_private.h
|
|
|
60de42 |
+++ b/lib/services/services_private.h
|
|
|
60de42 |
@@ -45,30 +45,44 @@ struct svc_action_private_s {
|
|
|
60de42 |
#endif
|
|
|
60de42 |
};
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
GList *services_os_get_directory_list(const char *root, gboolean files, gboolean executable);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean services_os_action_execute(svc_action_t * op, gboolean synchronous);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
GList *resources_os_list_lsb_agents(void);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
GList *resources_os_list_ocf_providers(void);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
GList *resources_os_list_ocf_agents(const char *provider);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
GList *resources_os_list_nagios_agents(void);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean cancel_recurring_action(svc_action_t * op);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean recurring_action_timer(gpointer data);
|
|
|
60de42 |
+
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean operation_finalize(svc_action_t * op);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
void services_add_inflight_op(svc_action_t *op);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
void handle_blocked_ops(void);
|
|
|
60de42 |
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean is_op_blocked(const char *rsc);
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_DBUS
|
|
|
60de42 |
+G_GNUC_INTERNAL
|
|
|
60de42 |
void services_set_op_pending(svc_action_t *op, DBusPendingCall *pending);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/pacemaker.spec.in b/pacemaker.spec.in
|
|
|
60de42 |
index 34a1076..6385350 100644
|
|
|
60de42 |
--- a/pacemaker.spec.in
|
|
|
60de42 |
+++ b/pacemaker.spec.in
|
|
|
60de42 |
@@ -190,7 +190,9 @@ BuildRequires: coreutils findutils grep sed
|
|
|
60de42 |
|
|
|
60de42 |
# Required for core functionality
|
|
|
60de42 |
BuildRequires: automake autoconf libtool pkgconfig libtool-ltdl-devel
|
|
|
60de42 |
-BuildRequires: pkgconfig(glib-2.0) libxml2-devel libxslt-devel libuuid-devel
|
|
|
60de42 |
+## version lower bound for: G_GNUC_INTERNAL
|
|
|
60de42 |
+BuildRequires: pkgconfig(glib-2.0) >= 2.6
|
|
|
60de42 |
+BuildRequires: libxml2-devel libxslt-devel libuuid-devel
|
|
|
60de42 |
BuildRequires: bzip2-devel pam-devel
|
|
|
60de42 |
|
|
|
60de42 |
# Required for agent_config.h which specifies the correct scratch directory
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 31adceb587c1beb90a0d61bb3bf1b634e5516d54 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Fri, 10 Feb 2017 10:50:59 +0100
|
|
|
60de42 |
Subject: [PATCH 4/6] Refactor: lib/services: ensure some objects not exported
|
|
|
60de42 |
accidentally
|
|
|
60de42 |
|
|
|
60de42 |
They are not tracked by neither public nor private API anyway.
|
|
|
60de42 |
See also a note about "symbol smog" in the previous commit.
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 6 +++---
|
|
|
60de42 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 4be425c..b1e3b26 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -37,11 +37,11 @@
|
|
|
60de42 |
/* TODO: Develop a rollover strategy */
|
|
|
60de42 |
|
|
|
60de42 |
static int operations = 0;
|
|
|
60de42 |
-GHashTable *recurring_actions = NULL;
|
|
|
60de42 |
+static GHashTable *recurring_actions = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
/* ops waiting to run async because of conflicting active
|
|
|
60de42 |
- * pending ops*/
|
|
|
60de42 |
-GList *blocked_ops = NULL;
|
|
|
60de42 |
+ * pending ops */
|
|
|
60de42 |
+static GList *blocked_ops = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
/* ops currently active (in-flight) */
|
|
|
60de42 |
GList *inflight_ops = NULL;
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From eeeabd732b67d478bb50101e1bb30324ca2c3d9a Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Thu, 9 Feb 2017 23:06:36 +0100
|
|
|
60de42 |
Subject: [PATCH 5/6] Refactor: lib/services: unify on single source of
|
|
|
60de42 |
"synchronous" flag
|
|
|
60de42 |
|
|
|
60de42 |
Forerunner systemd.[ch] is followed by the rest of squad in decision
|
|
|
60de42 |
based merely on svc_action_t operand with suitably flipped member item
|
|
|
60de42 |
and no more on redundant extraneous parameter that in turn is dropped.
|
|
|
60de42 |
It was (for the former) and is possible because both a/synchronous paths
|
|
|
60de42 |
leading to such decision contains a priori setting of the flag as
|
|
|
60de42 |
expected (in services_action_async/services_action_sync, respectively).
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 8 ++++----
|
|
|
60de42 |
lib/services/services_linux.c | 16 ++++++++--------
|
|
|
60de42 |
lib/services/services_private.h | 2 +-
|
|
|
60de42 |
lib/services/upstart.c | 2 +-
|
|
|
60de42 |
lib/services/upstart.h | 2 +-
|
|
|
60de42 |
5 files changed, 15 insertions(+), 15 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index b1e3b26..decb2cb 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -573,14 +573,14 @@ action_async_helper(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
if (op->standard && strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
- return upstart_job_exec(op, FALSE);
|
|
|
60de42 |
+ return upstart_job_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
} else if (op->standard && strcasecmp(op->standard, "systemd") == 0) {
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
return systemd_unit_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
} else {
|
|
|
60de42 |
- return services_os_action_execute(op, FALSE);
|
|
|
60de42 |
+ return services_os_action_execute(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
/* The 'op' has probably been freed if the execution functions return TRUE. */
|
|
|
60de42 |
/* Avoid using the 'op' in here. */
|
|
|
60de42 |
@@ -701,14 +701,14 @@ services_action_sync(svc_action_t * op)
|
|
|
60de42 |
op->synchronous = true;
|
|
|
60de42 |
if (op->standard && strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
- rc = upstart_job_exec(op, TRUE);
|
|
|
60de42 |
+ rc = upstart_job_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
} else if (op->standard && strcasecmp(op->standard, "systemd") == 0) {
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
rc = systemd_unit_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
} else {
|
|
|
60de42 |
- rc = services_os_action_execute(op, TRUE);
|
|
|
60de42 |
+ rc = services_os_action_execute(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
crm_trace(" > %s_%s_%d: %s = %d", op->rsc, op->action, op->interval, op->opaque->exec, op->rc);
|
|
|
60de42 |
if (op->stdout_data) {
|
|
|
60de42 |
diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c
|
|
|
60de42 |
index 16f25f3..adfefaa 100644
|
|
|
60de42 |
--- a/lib/services/services_linux.c
|
|
|
60de42 |
+++ b/lib/services/services_linux.c
|
|
|
60de42 |
@@ -606,7 +606,7 @@ action_synced_wait(svc_action_t * op, sigset_t *mask)
|
|
|
60de42 |
/* For an asynchronous 'op', returns FALSE if 'op' should be free'd by the caller */
|
|
|
60de42 |
/* For a synchronous 'op', returns FALSE if 'op' fails */
|
|
|
60de42 |
gboolean
|
|
|
60de42 |
-services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
+services_os_action_execute(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
int stdout_fd[2];
|
|
|
60de42 |
int stderr_fd[2];
|
|
|
60de42 |
@@ -641,7 +641,7 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
int rc = errno;
|
|
|
60de42 |
crm_warn("Cannot execute '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
|
|
|
60de42 |
services_handle_exec_error(op, rc);
|
|
|
60de42 |
- if (!synchronous) {
|
|
|
60de42 |
+ if (!op->synchronous) {
|
|
|
60de42 |
return operation_finalize(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
@@ -653,7 +653,7 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
crm_err("pipe(stdout_fd) failed. '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
|
|
|
60de42 |
|
|
|
60de42 |
services_handle_exec_error(op, rc);
|
|
|
60de42 |
- if (!synchronous) {
|
|
|
60de42 |
+ if (!op->synchronous) {
|
|
|
60de42 |
return operation_finalize(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
@@ -668,13 +668,13 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
crm_err("pipe(stderr_fd) failed. '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
|
|
|
60de42 |
|
|
|
60de42 |
services_handle_exec_error(op, rc);
|
|
|
60de42 |
- if (!synchronous) {
|
|
|
60de42 |
+ if (!op->synchronous) {
|
|
|
60de42 |
return operation_finalize(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (synchronous) {
|
|
|
60de42 |
+ if (op->synchronous) {
|
|
|
60de42 |
#ifdef HAVE_SYS_SIGNALFD_H
|
|
|
60de42 |
sigemptyset(&mask);
|
|
|
60de42 |
sigaddset(&mask, SIGCHLD);
|
|
|
60de42 |
@@ -717,7 +717,7 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
|
|
|
60de42 |
crm_err("Could not execute '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
|
|
|
60de42 |
services_handle_exec_error(op, rc);
|
|
|
60de42 |
- if (!synchronous) {
|
|
|
60de42 |
+ if (!op->synchronous) {
|
|
|
60de42 |
return operation_finalize(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -740,7 +740,7 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
close(stderr_fd[1]);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (synchronous) {
|
|
|
60de42 |
+ if (op->synchronous) {
|
|
|
60de42 |
sigchld_cleanup();
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -758,7 +758,7 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
op->opaque->stderr_fd = stderr_fd[0];
|
|
|
60de42 |
set_fd_opts(op->opaque->stderr_fd, O_NONBLOCK);
|
|
|
60de42 |
|
|
|
60de42 |
- if (synchronous) {
|
|
|
60de42 |
+ if (op->synchronous) {
|
|
|
60de42 |
action_synced_wait(op, pmask);
|
|
|
60de42 |
sigchld_cleanup();
|
|
|
60de42 |
} else {
|
|
|
60de42 |
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
|
|
|
60de42 |
index 41895a9..ec9e1c4 100644
|
|
|
60de42 |
--- a/lib/services/services_private.h
|
|
|
60de42 |
+++ b/lib/services/services_private.h
|
|
|
60de42 |
@@ -49,7 +49,7 @@ G_GNUC_INTERNAL
|
|
|
60de42 |
GList *services_os_get_directory_list(const char *root, gboolean files, gboolean executable);
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL
|
|
|
60de42 |
-gboolean services_os_action_execute(svc_action_t * op, gboolean synchronous);
|
|
|
60de42 |
+gboolean services_os_action_execute(svc_action_t * op);
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL
|
|
|
60de42 |
GList *resources_os_list_lsb_agents(void);
|
|
|
60de42 |
diff --git a/lib/services/upstart.c b/lib/services/upstart.c
|
|
|
60de42 |
index 5651a14..a17c2bf 100644
|
|
|
60de42 |
--- a/lib/services/upstart.c
|
|
|
60de42 |
+++ b/lib/services/upstart.c
|
|
|
60de42 |
@@ -414,7 +414,7 @@ upstart_async_dispatch(DBusPendingCall *pending, void *user_data)
|
|
|
60de42 |
/* For an asynchronous 'op', returns FALSE if 'op' should be free'd by the caller */
|
|
|
60de42 |
/* For a synchronous 'op', returns FALSE if 'op' fails */
|
|
|
60de42 |
gboolean
|
|
|
60de42 |
-upstart_job_exec(svc_action_t * op, gboolean synchronous)
|
|
|
60de42 |
+upstart_job_exec(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
char *job = NULL;
|
|
|
60de42 |
int arg_wait = TRUE;
|
|
|
60de42 |
diff --git a/lib/services/upstart.h b/lib/services/upstart.h
|
|
|
60de42 |
index 8d41c11..6954943 100644
|
|
|
60de42 |
--- a/lib/services/upstart.h
|
|
|
60de42 |
+++ b/lib/services/upstart.h
|
|
|
60de42 |
@@ -23,7 +23,7 @@
|
|
|
60de42 |
# include "crm/services.h"
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL GList *upstart_job_listall(void);
|
|
|
60de42 |
-G_GNUC_INTERNAL gboolean upstart_job_exec(svc_action_t * op, gboolean synchronous);
|
|
|
60de42 |
+G_GNUC_INTERNAL gboolean upstart_job_exec(svc_action_t * op);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean upstart_job_exists(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL gboolean upstart_job_running(const gchar * name);
|
|
|
60de42 |
G_GNUC_INTERNAL void upstart_cleanup(void);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 6e64b585ba628ef93d99fc17a6a880a76505e27d Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
60de42 |
Date: Thu, 9 Feb 2017 23:28:24 +0100
|
|
|
60de42 |
Subject: [PATCH 6/6] Refactor: lib/services: async_helper -> versatile
|
|
|
60de42 |
exec_helper
|
|
|
60de42 |
|
|
|
60de42 |
Also mark it inline just in case the compiler won't get it that it's
|
|
|
60de42 |
just another form of up-to-singly-nested ternary operator making for
|
|
|
60de42 |
a tail call.
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 24 ++++++++----------------
|
|
|
60de42 |
1 file changed, 8 insertions(+), 16 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index decb2cb..0b535e6 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -568,9 +568,10 @@ handle_duplicate_recurring(svc_action_t * op, void (*action_callback) (svc_actio
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
-static gboolean
|
|
|
60de42 |
-action_async_helper(svc_action_t * op)
|
|
|
60de42 |
+inline static gboolean
|
|
|
60de42 |
+action_exec_helper(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
+ /* Whether a/synchronous must be decided (op->synchronous) beforehand. */
|
|
|
60de42 |
if (op->standard && strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
return upstart_job_exec(op);
|
|
|
60de42 |
@@ -582,7 +583,8 @@ action_async_helper(svc_action_t * op)
|
|
|
60de42 |
} else {
|
|
|
60de42 |
return services_os_action_execute(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
- /* The 'op' has probably been freed if the execution functions return TRUE. */
|
|
|
60de42 |
+ /* The 'op' has probably been freed if the execution functions return TRUE
|
|
|
60de42 |
+ for the asynchronous 'op'. */
|
|
|
60de42 |
/* Avoid using the 'op' in here. */
|
|
|
60de42 |
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
@@ -625,7 +627,7 @@ services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *
|
|
|
60de42 |
return TRUE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- return action_async_helper(op);
|
|
|
60de42 |
+ return action_exec_helper(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
@@ -670,7 +672,7 @@ handle_blocked_ops(void)
|
|
|
60de42 |
continue;
|
|
|
60de42 |
}
|
|
|
60de42 |
executed_ops = g_list_append(executed_ops, op);
|
|
|
60de42 |
- res = action_async_helper(op);
|
|
|
60de42 |
+ res = action_exec_helper(op);
|
|
|
60de42 |
if (res == FALSE) {
|
|
|
60de42 |
op->status = PCMK_LRM_OP_ERROR;
|
|
|
60de42 |
/* this can cause this function to be called recursively
|
|
|
60de42 |
@@ -699,17 +701,7 @@ services_action_sync(svc_action_t * op)
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
op->synchronous = true;
|
|
|
60de42 |
- if (op->standard && strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
-#if SUPPORT_UPSTART
|
|
|
60de42 |
- rc = upstart_job_exec(op);
|
|
|
60de42 |
-#endif
|
|
|
60de42 |
- } else if (op->standard && strcasecmp(op->standard, "systemd") == 0) {
|
|
|
60de42 |
-#if SUPPORT_SYSTEMD
|
|
|
60de42 |
- rc = systemd_unit_exec(op);
|
|
|
60de42 |
-#endif
|
|
|
60de42 |
- } else {
|
|
|
60de42 |
- rc = services_os_action_execute(op);
|
|
|
60de42 |
- }
|
|
|
60de42 |
+ rc = action_exec_helper(op);
|
|
|
60de42 |
crm_trace(" > %s_%s_%d: %s = %d", op->rsc, op->action, op->interval, op->opaque->exec, op->rc);
|
|
|
60de42 |
if (op->stdout_data) {
|
|
|
60de42 |
crm_trace(" > stdout: %s", op->stdout_data);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|