gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: fix event loop subscriptions on DB recon


From: gnunet
Subject: [gnunet] branch master updated: fix event loop subscriptions on DB reconnect
Date: Thu, 25 Nov 2021 14:03:21 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new b9644ee30 fix event loop subscriptions on DB reconnect
     new fff38c7f0 Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
b9644ee30 is described below

commit b9644ee3066924eefa8ea2b75fbd20538ad7ce03
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Nov 25 14:03:04 2021 +0100

    fix event loop subscriptions on DB reconnect
---
 src/pq/pq_event.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c
index 283e4569c..98a28c317 100644
--- a/src/pq/pq_event.c
+++ b/src/pq/pq_event.c
@@ -194,9 +194,15 @@ event_do_poll (struct GNUNET_PQ_Context *db)
               "PG poll job active\n");
   if (1 !=
       PQconsumeInput (db->conn))
+  {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Failed to read from Postgres: %s\n",
                 PQerrorMessage (db->conn));
+    if (CONNECTION_BAD != PQstatus (db->conn))
+      return;
+    GNUNET_PQ_reconnect (db);
+    return;
+  }
   while (NULL != (n = PQnotifies (db->conn)))
   {
     struct GNUNET_ShortHashCode sh;
@@ -263,10 +269,20 @@ do_scheduler_notify (void *cls)
   struct GNUNET_PQ_Context *db = cls;
 
   db->event_task = NULL;
-  GNUNET_assert (NULL != db->rfd);
+  if (NULL == db->rfd)
+    GNUNET_PQ_reconnect (db);
   event_do_poll (db);
+  if (NULL != db->event_task)
+    return;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Resubscribing\n");
+  if (NULL == db->rfd)
+  {
+    db->event_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                                   &do_scheduler_notify,
+                                                   db);
+    return;
+  }
   db->event_task
     = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
                                      db->rfd,
@@ -329,6 +345,8 @@ manage_subscribe (struct GNUNET_PQ_Context *db,
   char *end;
   PGresult *result;
 
+  if (NULL == db->conn)
+    return;
   end = stpcpy (sql,
                 cmd);
   end = sh_to_channel (&eh->sh,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]