Skip to content

Commit

Permalink
Fix: Perform systemd reloads asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
beekhof committed Oct 30, 2014
1 parent a9c8177 commit a7cf095
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/crm/common/logging.h
Expand Up @@ -157,7 +157,7 @@ unsigned int get_crm_log_level(void);
} \
} while(0)

# define do_crm_log_always(level, fmt, args...) qb_log(level, "%s: " fmt, __FUNCTION__ , ##args)
# define do_crm_log_always(level, fmt, args...) qb_log(level, fmt , ##args)

# define crm_perror(level, fmt, args...) do { \
const char *err = strerror(errno); \
Expand Down
7 changes: 5 additions & 2 deletions lib/services/dbus.c
Expand Up @@ -169,7 +169,7 @@ bool pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection,

}

if (dbus_pending_call_get_completed(pending)) {
if (done && dbus_pending_call_get_completed(pending)) {
crm_info("DBus %s call completed too soon");
#if 1
/* This sounds like a good idea, but allegedly it breaks things */
Expand All @@ -178,8 +178,11 @@ bool pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection,
CRM_ASSERT(dbus_pending_call_set_notify(pending, done, user_data, NULL));
#endif

} else {
} else if(done) {
CRM_ASSERT(dbus_pending_call_set_notify(pending, done, user_data, NULL));

} else {
crm_info("DBus %s call completed too soon");
}
return TRUE;
}
Expand Down
35 changes: 29 additions & 6 deletions lib/services/systemd.c
Expand Up @@ -110,20 +110,43 @@ systemd_service_name(const char *name)
return g_strdup_printf("%s.service", name);
}

static void
systemd_daemon_reload_complete(DBusPendingCall *pending, void *user_data)
{
DBusError error;
DBusMessage *reply = NULL;
int *reload_count = user_data;

dbus_error_init(&error);
if(pending) {
reply = dbus_pending_call_steal_reply(pending);
}

if(pcmk_dbus_find_error("Reload", pending, reply, &error)) {
crm_err("Could not issue systemd reload %d: %s", *reload_count, error.message);

} else {
crm_trace("Reload %d complete", *reload_count);
}

if(pending) {
dbus_pending_call_unref(pending);
}
if(reply) {
dbus_message_unref(reply);
}
}

static bool
systemd_daemon_reload(void)
{
/* TODO: Make this asynchronous */
static int reload_count = 0;
const char *method = "Reload";
DBusMessage *reply = NULL;
DBusMessage *msg = systemd_new_method(BUS_NAME".Manager", method);

CRM_ASSERT(msg != NULL);
reply = pcmk_dbus_send_recv(msg, systemd_proxy, NULL);
pcmk_dbus_send(msg, systemd_proxy, systemd_daemon_reload_complete, &reload_count);
dbus_message_unref(msg);
if(reply) {
dbus_message_unref(reply);
}
return TRUE;
}

Expand Down

0 comments on commit a7cf095

Please sign in to comment.