aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-01-09 20:45:16 +0100
committerChristian Grothoff <christian@grothoff.org>2023-01-09 20:45:19 +0100
commitbe0ba43d7a81a8e44c047b93e8c19cc30d2f983a (patch)
tree186384ec0f98fea28a5dab42fef4d12125da887a
parent9ac05df446dc67f2fd937b9a54c3cc6050907e69 (diff)
downloadgnunet-be0ba43d7a81a8e44c047b93e8c19cc30d2f983a.tar.gz
gnunet-be0ba43d7a81a8e44c047b93e8c19cc30d2f983a.zip
PQ: use exponential back-off when reconnecting to the database to listen on events
-rw-r--r--src/pq/pq.h5
-rw-r--r--src/pq/pq_event.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/src/pq/pq.h b/src/pq/pq.h
index 85cfcc070..f9b59e058 100644
--- a/src/pq/pq.h
+++ b/src/pq/pq.h
@@ -90,6 +90,11 @@ struct GNUNET_PQ_Context
90 struct GNUNET_NETWORK_Handle *rfd; 90 struct GNUNET_NETWORK_Handle *rfd;
91 91
92 /** 92 /**
93 * How fast should we resubscribe again?
94 */
95 struct GNUNET_TIME_Relative resubscribe_backoff;
96
97 /**
93 * Flags controlling the connection. 98 * Flags controlling the connection.
94 */ 99 */
95 enum GNUNET_PQ_Options flags; 100 enum GNUNET_PQ_Options flags;
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c
index b0ed6798a..6dbacf7ff 100644
--- a/src/pq/pq_event.c
+++ b/src/pq/pq_event.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021, 2023 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -283,11 +283,17 @@ do_scheduler_notify (void *cls)
283 "Resubscribing\n"); 283 "Resubscribing\n");
284 if (NULL == db->rfd) 284 if (NULL == db->rfd)
285 { 285 {
286 db->resubscribe_backoff
287 = GNUNET_TIME_relative_max (db->resubscribe_backoff,
288 GNUNET_TIME_UNIT_SECONDS);
289 db->resubscribe_backoff
290 = GNUNET_TIME_STD_BACKOFF (db->resubscribe_backoff);
286 db->event_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 291 db->event_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
287 &do_scheduler_notify, 292 &do_scheduler_notify,
288 db); 293 db);
289 return; 294 return;
290 } 295 }
296 db->resubscribe_backoff = GNUNET_TIME_UNIT_SECONDS;
291 db->event_task 297 db->event_task
292 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 298 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
293 db->rfd, 299 db->rfd,
@@ -387,7 +393,7 @@ manage_subscribe (struct GNUNET_PQ_Context *db,
387 * @param value the event handler 393 * @param value the event handler
388 * @return #GNUNET_OK to continue to iterate 394 * @return #GNUNET_OK to continue to iterate
389 */ 395 */
390static int 396static enum GNUNET_GenericReturnValue
391register_notify (void *cls, 397register_notify (void *cls,
392 const struct GNUNET_ShortHashCode *sh, 398 const struct GNUNET_ShortHashCode *sh,
393 void *value) 399 void *value)