summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-11 23:20:13 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-11 23:36:09 +0200
commit195fd08b9f0f46efd63dd87fb8f5fdbaca8ca610 (patch)
treefa276199ebd059bd6a957e172b814b9aa2b922fd
parente3e21acb23283915c97e6ef1c167325f4592665c (diff)
add GNUNET_PQ_reconnect_if_down
-rw-r--r--src/include/gnunet_pq_lib.h9
-rw-r--r--src/pq/pq_connect.c14
2 files changed, 23 insertions, 0 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index a56df21fd..2aea77b7f 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -749,6 +749,15 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
/**
+ * Reinitialize the database @a db if the connection is down.
+ *
+ * @param db database connection to reinitialize
+ */
+void
+GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db);
+
+
+/**
* Reinitialize the database @a db.
*
* @param db database connection to reinitialize
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index 7599f4b15..882df4f89 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -128,6 +128,20 @@ GNUNET_PQ_connect (const char *config_str,
/**
+ * Reinitialize the database @a db if the connection is down.
+ *
+ * @param db database connection to reinitialize
+ */
+void
+GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db)
+{
+ if (CONNECTION_BAD != PQstatus (db->conn))
+ return;
+ GNUNET_PQ_reconnect (db);
+}
+
+
+/**
* Reinitialize the database @a db.
*
* @param db database connection to reinitialize