diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-01-09 20:45:16 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-01-09 20:45:19 +0100 |
commit | be0ba43d7a81a8e44c047b93e8c19cc30d2f983a (patch) | |
tree | 186384ec0f98fea28a5dab42fef4d12125da887a /src/pq/pq_event.c | |
parent | 9ac05df446dc67f2fd937b9a54c3cc6050907e69 (diff) | |
download | gnunet-be0ba43d7a81a8e44c047b93e8c19cc30d2f983a.tar.gz gnunet-be0ba43d7a81a8e44c047b93e8c19cc30d2f983a.zip |
PQ: use exponential back-off when reconnecting to the database to listen on events
Diffstat (limited to 'src/pq/pq_event.c')
-rw-r--r-- | src/pq/pq_event.c | 10 |
1 files changed, 8 insertions, 2 deletions
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 | */ |
390 | static int | 396 | static enum GNUNET_GenericReturnValue |
391 | register_notify (void *cls, | 397 | register_notify (void *cls, |
392 | const struct GNUNET_ShortHashCode *sh, | 398 | const struct GNUNET_ShortHashCode *sh, |
393 | void *value) | 399 | void *value) |