meta-openembedded/meta-networking/recipes-support/pgpool2/pgpool2/0001-fix-compiling-on-32-bit-systems.patch
Gyorgy Sarvari 0601a0bd8f
pgpool2: update patch statuses
The patches were submitted to upstream, they are not pending anymore.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-09-15 09:55:16 -07:00

84 lines
3.4 KiB
Diff

From 523ca5546b0178be693943f2a3a880c0bd6ea239 Mon Sep 17 00:00:00 2001
From: Gyorgy Sarvari <skandigraun@gmail.com>
Date: Thu, 11 Sep 2025 12:36:29 +0200
Subject: [PATCH] fix compiling on 32-bit systems
The timespec struct's tv_sec size can change between architectures.
Usually on 64 bit systems it's long, but on 32 bit systems it is frequently long long.
When the watchdog is trying to get the uptime, it is trying to get the value
as long - however on 32 bit systems this fails due to different time_t size:
| wd_json_data.c:540:66: error: passing argument 3 of 'json_get_long_value_for_key' from incompatible pointer type [-Wincompatible-pointer-types]
| 540 | if (json_get_long_value_for_key(root, "StartupTimeSecs", &wdNode->startup_time.tv_sec))
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
To account for this, introduce a new helper function to get a json value as
a time_t type.
Upstream-Status: Submitted [https://github.com/pgpool/pgpool2/pull/128]
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
src/include/utils/json.h | 5 +++--
src/utils/json.c | 14 ++++++++++++++
src/watchdog/wd_json_data.c | 2 +-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/include/utils/json.h b/src/include/utils/json.h
index 67cc0255a..93be83c3a 100644
--- a/src/include/utils/json.h
+++ b/src/include/utils/json.h
@@ -311,10 +311,11 @@ extern "C"
#endif
/* pgpool-II extensions */
-json_value *json_get_value_for_key(json_value * source, const char *key);
+json_value *json_get_value_for_key(json_value * source, const char *key);
int json_get_int_value_for_key(json_value * source, const char *key, int *value);
int json_get_long_value_for_key(json_value * source, const char *key, long *value);
-char *json_get_string_value_for_key(json_value * source, const char *key);
+char *json_get_string_value_for_key(json_value * source, const char *key);
int json_get_bool_value_for_key(json_value * source, const char *key, bool *value);
+int json_get_time_value_for_key(json_value * source, const char *key, time_t *value);
#endif
diff --git a/src/utils/json.c b/src/utils/json.c
index 319c8fdbf..bce99466c 100644
--- a/src/utils/json.c
+++ b/src/utils/json.c
@@ -1204,6 +1204,20 @@ json_get_long_value_for_key(json_value * source, const char *key, long *value)
return 0;
}
+int
+json_get_time_value_for_key(json_value * source, const char *key, time_t *value)
+{
+ json_value *jNode;
+
+ jNode = json_get_value_for_key(source, key);
+ if (jNode == NULL)
+ return -1;
+ if (jNode->type != json_integer)
+ return -1;
+ *value = jNode->u.integer;
+ return 0;
+}
+
/*
* pgpool extension:
* returns string value if found for the key.
diff --git a/src/watchdog/wd_json_data.c b/src/watchdog/wd_json_data.c
index 474fc37a4..53053cd4b 100644
--- a/src/watchdog/wd_json_data.c
+++ b/src/watchdog/wd_json_data.c
@@ -537,7 +537,7 @@ get_watchdog_node_from_json(char *json_data, int data_len, char **authkey)
if (root == NULL || root->type != json_object)
goto ERROR_EXIT;
- if (json_get_long_value_for_key(root, "StartupTimeSecs", &wdNode->startup_time.tv_sec))
+ if (json_get_time_value_for_key(root, "StartupTimeSecs", &wdNode->startup_time.tv_sec))
{
bool escalated;
long seconds_since_node_startup;