commit 94e489daaab2a378108f1040dfae7ce5e340510b
parent 014bf263a4f4631cfbab6486a3af069524e98ec6
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Wed, 1 Jul 2026 17:01:25 +0200
fix #11593
Diffstat:
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/donaudb/helper.h b/src/donaudb/helper.h
@@ -56,16 +56,17 @@ struct DONAUDB_PostgresContext
*/
const char *transaction_name;
- /**
- * Counts how often we have established a fresh @e conn
- * to the database. Used to re-prepare statements.
- */
- unsigned long long prep_gen;
-
};
/**
+ * Counts how often we have established a fresh @e conn
+ * to the database. Used to re-prepare statements.
+ */
+extern unsigned long long DONAUDB_prep_gen_;
+
+
+/**
* Prepares SQL statement @a sql under @a name for
* connection @a pg once.
* Returns with #GNUNET_DB_STATUS_HARD_ERROR on failure.
@@ -88,7 +89,7 @@ struct DONAUDB_PostgresContext
off++; \
GNUNET_assert (off < \
sizeof(preps) / sizeof(*preps)); \
- if (preps[off].cnt < ctx->prep_gen) \
+ if (preps[off].cnt < DONAUDB_prep_gen_) \
{ \
struct GNUNET_PQ_PreparedStatement ps[] = { \
GNUNET_PQ_make_prepare (name, sql), \
@@ -103,7 +104,7 @@ struct DONAUDB_PostgresContext
return GNUNET_DB_STATUS_HARD_ERROR; \
} \
preps[off].pg = ctx; \
- preps[off].cnt = pg->prep_gen; \
+ preps[off].cnt = DONAUDB_prep_gen_; \
} \
} while (0)
diff --git a/src/donaudb/plugin_donaudb_postgres.c b/src/donaudb/plugin_donaudb_postgres.c
@@ -37,6 +37,12 @@ struct DONAUDB_PostgresContext;
/**
+ * Counts how often we have established a fresh @e conn
+ * to the database. Used to re-prepare statements.
+ */
+unsigned long long DONAUDB_prep_gen_;
+
+/**
* Function called each time we connect or reconnect to the
* database. Gives the application a chance to run some
* per-connection initialization logic.
@@ -84,7 +90,7 @@ reconnect_cb (struct DONAUDB_PostgresContext *pg,
GNUNET_break (0);
return;
}
- pg->prep_gen++;
+ DONAUDB_prep_gen_++;
}
@@ -107,7 +113,7 @@ internal_setup (struct DONAUDB_PostgresContext *pg)
pg);
if (NULL == db_conn)
return GNUNET_SYSERR;
- if (0 == pg->prep_gen)
+ if (0 == DONAUDB_prep_gen_)
{
GNUNET_PQ_disconnect (db_conn);
return GNUNET_SYSERR;