pgpool2.git / summary / log / commit / refs
commit 33f17e75e64034cb206bb76d457ae7c5ddf8b233
Author: Muhammad Usama <m.usama@gmail.com>
Date: Thu Oct 03 14:53:44 2019 +0000
Fix for Coverity warnings in watchdog and lifecheck
src/watchdog/watchdog.c | 27 ++++++++++++++++++++++++---
src/watchdog/wd_lifecheck.c | 7 +++++++
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
index 0a0e81ef6..c240717da 100644
--- a/src/watchdog/watchdog.c
+++ b/src/watchdog/watchdog.c
@@ -2784,7 +2784,14 @@ static IPC_CMD_PREOCESS_RES process_IPC_failover_indication(WDCommandData * ipcC
if (root && root->type == json_object)
{
- json_get_int_value_for_key(root, "FailoverFuncState", &failoverState);
+ if (json_get_int_value_for_key(root, "FailoverFuncState", &failoverState))
+ {
+ ereport(LOG,
+ (errmsg("unable to process failover indication"),
+ errdetail("failed to get failover state from json data in command packet")));
+ res = FAILOVER_RES_INVALID_FUNCTION;
+ }
+
}
else
{
@@ -4221,6 +4228,8 @@ node_lost_while_ipc_command(WatchdogNode * wdNode)
cleanUpIPCCommand(ipcCommand);
}
+
+ list_free(ipcCommands_to_del);
}
@@ -4313,6 +4322,8 @@ service_internal_command(void)
g_cluster.clusterCommands = list_delete_ptr(g_cluster.clusterCommands, clusterCommand);
MemoryContextDelete(clusterCommand->memoryContext);
}
+
+ list_free(finishedCommands);
}
/* remove the unreachable nodes from cluster */
@@ -4470,6 +4481,8 @@ check_for_current_command_timeout(void)
g_cluster.clusterCommands = list_delete_ptr(g_cluster.clusterCommands, clusterCommand);
MemoryContextDelete(clusterCommand->memoryContext);
}
+
+ list_free(finishedCommands);
}
@@ -4553,6 +4566,9 @@ issue_watchdog_internal_command(WatchdogNode * wdNode, WDPacketData * pkt, int t
if (nodeResult == NULL)
{
/* should never hapen */
+ ereport(WARNING,
+ (errmsg("Internal error. Not able to locate node result slot")));
+ MemoryContextDelete(clusterCommand->memoryContext);
return -1;
}
if (send_message_to_node(nodeResult->wdNode, pkt) == false)
@@ -5015,6 +5031,9 @@ watchdog_state_machine(WD_EVENTS event, WatchdogNode * wdNode, WDPacketData * pk
ereport(DEBUG1,
(errmsg("IP = %s", ip ? ip : "NULL")));
}
+
+ list_free_deep(local_addresses);
+ local_addresses = NULL;
}
}
@@ -5657,9 +5676,9 @@ watchdog_state_machine_coordinator(WD_EVENTS event, WatchdogNode * wdNode, WDPac
*/
wd_IP_up();
}
- list_free_deep(local_addresses);
- local_addresses = NULL;
}
+ list_free_deep(local_addresses);
+ local_addresses = NULL;
}
}
break;
@@ -6760,6 +6779,8 @@ process_wd_func_commands_for_timer_events(void)
{
g_cluster.wd_timer_commands = list_delete_ptr(g_cluster.wd_timer_commands, lfirst(lc));
}
+
+ list_free(timers_to_del);
}
static void
diff --git a/src/watchdog/wd_lifecheck.c b/src/watchdog/wd_lifecheck.c
index 75d2e835d..15e5667c5 100644
--- a/src/watchdog/wd_lifecheck.c
+++ b/src/watchdog/wd_lifecheck.c
@@ -827,6 +827,13 @@ check_pgpool_status_by_query(void)
thread_arg[i].lifeCheckNode = node;
thread_arg[i].password = password;
rc = watchdog_thread_create(&thread[i], &attr, thread_ping_pgpool, (void *) &thread_arg[i]);
+ if (rc)
+ {
+ ereport(WARNING,
+ (errmsg("failed to create thread for checking pgpool status by query for %d (%s:%d)",
+ i, node->hostName, node->pgpoolPort),
+ errdetail("pthread_create failed with error code %d: %s",rc, strerror(rc))));
+ }
}
pthread_attr_destroy(&attr);
[parent: d339cf86055b]