Skip to content

Commit

Permalink
Merge pull request #1400 from kgaillot/fixes11
Browse files Browse the repository at this point in the history
Pull recent memory leak fixes from 2.0 branch
  • Loading branch information
kgaillot committed Dec 18, 2017
2 parents ddc8933 + 69de188 commit 8a70419
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 20 deletions.
1 change: 1 addition & 0 deletions attrd/commands.c
Expand Up @@ -539,6 +539,7 @@ attrd_broadcast_protocol()
crm_xml_add(attrd_op, F_ATTRD_VALUE, ATTRD_PROTOCOL_VERSION);
crm_xml_add_int(attrd_op, F_ATTRD_IS_PRIVATE, 1);
attrd_client_update(attrd_op);
free_xml(attrd_op);
}

void
Expand Down
1 change: 0 additions & 1 deletion cts/CTSaudits.py
Expand Up @@ -190,7 +190,6 @@ def __call__(self):

if answer and answer == "n":
raise ValueError("Disk full on %s" % (node))
ret = 0

elif remaining_mb < 100 or used_percent > 90:
self.CM.log("WARN: Low on log disk space (%dMB) on %s" % (remaining_mb, node))
Expand Down
1 change: 0 additions & 1 deletion cts/environment.py
Expand Up @@ -182,7 +182,6 @@ def set_stack(self, name):

else:
raise ValueError("Unknown stack: "+name)
sys.exit(1)

def get_stack_short(self):
# Create the Cluster Manager object
Expand Down
5 changes: 1 addition & 4 deletions cts/remote.py
Expand Up @@ -220,10 +220,7 @@ def __call__(self, node, command, stdout=0, synchronous=1, silent=False, blockin

if not silent:
for err in errors:
if stdout == 3:
result.append("error: "+err)
else:
self.debug("cmd: stderr: %s" % err)
self.debug("cmd: stderr: %s" % err)

if stdout == 0:
if not silent and result:
Expand Down
6 changes: 3 additions & 3 deletions cts/watcher.py
Expand Up @@ -337,19 +337,19 @@ def __init__(self, log, regexes, name="Anon", timeout=10, debug_level=None, sile
self.kind = kind
else:
raise
self.kind = self.Env["LogWatcher"]
#self.kind = self.Env["LogWatcher"]

if log:
self.filename = log
else:
raise
self.filename = self.Env["LogFileName"]
#self.filename = self.Env["LogFileName"]

if hosts:
self.hosts = hosts
else:
raise
self.hosts = self.Env["nodes"]
#self.hosts = self.Env["nodes"]

if trace_lw:
self.debug_level = 3
Expand Down
47 changes: 37 additions & 10 deletions lib/services/dbus.c
Expand Up @@ -23,6 +23,15 @@ struct db_getall_data {
void (*callback)(const char *name, const char *value, void *userdata);
};

static void
free_db_getall_data(struct db_getall_data *data)
{
free(data->target);
free(data->object);
free(data->name);
free(data);
}

DBusConnection *
pcmk_dbus_connect(void)
{
Expand Down Expand Up @@ -196,6 +205,20 @@ pcmk_dbus_send_recv(DBusMessage *msg, DBusConnection *connection,
return reply;
}

/*!
* \internal
* \brief Send a DBus message with a callback for the reply
*
* \param[in] msg DBus message to send
* \param[in,out] connection DBus connection to send on
* \param[in] done Function to call when pending call completes
* \param[in] user_data Data to pass to done callback
*
* \return Handle for reply on success, NULL on error
* \note The caller can assume that the done callback is called always and
* only when the return value is non-NULL. (This allows the caller to
* know where it should free dynamically allocated user_data.)
*/
DBusPendingCall *
pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection,
void(*done)(DBusPendingCall *pending, void *user_data),
Expand Down Expand Up @@ -359,11 +382,7 @@ pcmk_dbus_lookup_result(DBusMessage *reply, struct db_getall_data *data)
}

cleanup:
free(data->target);
free(data->object);
free(data->name);
free(data);

free_db_getall_data(data);
return output;
}

Expand Down Expand Up @@ -424,11 +443,19 @@ pcmk_dbus_get_property(DBusConnection *connection, const char *target,
query_data->name = strdup(name);
}

if(query_data->callback) {
DBusPendingCall* _pending;
_pending = pcmk_dbus_send(msg, connection, pcmk_dbus_lookup_cb, query_data, timeout);
if (pending != NULL) {
*pending = _pending;
if (query_data->callback) {
DBusPendingCall *local_pending;

local_pending = pcmk_dbus_send(msg, connection, pcmk_dbus_lookup_cb,
query_data, timeout);
if (local_pending == NULL) {
// pcmk_dbus_lookup_cb() was not called in this case
free_db_getall_data(query_data);
query_data = NULL;
}

if (pending) {
*pending = local_pending;
}

} else {
Expand Down
3 changes: 3 additions & 0 deletions lrmd/pacemaker_remote.service.in
Expand Up @@ -2,8 +2,11 @@
Description=Pacemaker Remote Service
Documentation=man:pacemaker_remoted http://clusterlabs.org/doc/en-US/Pacemaker/1.1-pcs/html/Pacemaker_Remote/index.html

# See main pacemaker unit file for descriptions of why these are needed
After=network.target
After=time-sync.target
After=dbus.service
Wants=dbus.service
After=resource-agents-deps.target
Wants=resource-agents-deps.target
After=syslog.service
Expand Down
4 changes: 4 additions & 0 deletions mcp/pacemaker.service.in
Expand Up @@ -14,6 +14,10 @@ After=network.target
# and failure timestamps, so wait until it's done.
After=time-sync.target

# Managing systemd resources requires DBus.
After=dbus.service
Wants=dbus.service

# Some OCF resources may have dependencies that aren't managed by the cluster;
# these must be started before Pacemaker and stopped after it. The
# resource-agents package provides this target, which lets system adminstrators
Expand Down
3 changes: 2 additions & 1 deletion pengine/clone.c
Expand Up @@ -955,6 +955,7 @@ is_child_compatible(resource_t *child_rsc, node_t * local_node, enum rsc_role_e
node_t *node = NULL;
enum rsc_role_e next_role = child_rsc->fns->state(child_rsc, current);

CRM_CHECK(child_rsc && local_node, return FALSE);
if (is_set_recursive(child_rsc, pe_rsc_block, TRUE) == FALSE) {
/* We only want instances that haven't failed */
node = child_rsc->fns->location(child_rsc, NULL, current);
Expand All @@ -965,7 +966,7 @@ is_child_compatible(resource_t *child_rsc, node_t * local_node, enum rsc_role_e
return FALSE;
}

if (node && local_node && node->details == local_node->details) {
if (node && (node->details == local_node->details)) {
return TRUE;

} else if (node) {
Expand Down
1 change: 1 addition & 0 deletions pengine/utilization.c
Expand Up @@ -341,6 +341,7 @@ process_utilization(resource_t * rsc, node_t ** prefer, pe_working_set_t * data_
{
int alloc_details = scores_log_level + 1;

CRM_CHECK(rsc && prefer && data_set, return);
if (safe_str_neq(data_set->placement_strategy, "default")) {
GHashTableIter iter;
GListPtr colocated_rscs = NULL;
Expand Down

0 comments on commit 8a70419

Please sign in to comment.