commit a4cae0dff0be3d39d70c4010019808f033940b80
parent 7ee0dab6e99668df6f33293d9efbfd147c82191f
Author: Jacki <jacki@thejackimonster.de>
Date: Sun, 28 Apr 2024 21:16:37 +0200
Delay and merge refresh messages
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
@@ -189,12 +189,14 @@ handle_destroy (struct GNUNET_CHAT_Handle *handle)
GNUNET_SCHEDULER_cancel(handle->destruction);
if (handle->disconnection)
GNUNET_SCHEDULER_cancel(handle->disconnection);
-
- handle->disconnection = NULL;
+ if (handle->refresh)
+ GNUNET_SCHEDULER_cancel(handle->refresh);
if (handle->monitor)
GNUNET_NAMESTORE_zone_monitor_stop(handle->monitor);
+ handle->disconnection = NULL;
+
if (handle->current)
handle_disconnect(handle);
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
@@ -88,6 +88,7 @@ struct GNUNET_CHAT_Handle
struct GNUNET_SCHEDULER_Task *shutdown_hook;
struct GNUNET_SCHEDULER_Task *destruction;
struct GNUNET_SCHEDULER_Task *disconnection;
+ struct GNUNET_SCHEDULER_Task *refresh;
struct GNUNET_CHAT_InternalServices *services_head;
struct GNUNET_CHAT_InternalServices *services_tail;
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -276,6 +276,24 @@ notify_handle_fs_progress(void* cls,
return NULL;
}
+static void
+on_handle_refresh (void *cls)
+{
+ GNUNET_assert(cls);
+
+ struct GNUNET_CHAT_Handle* handle = cls;
+
+ handle->refresh = NULL;
+
+ handle_send_internal_message(
+ handle,
+ NULL,
+ NULL,
+ GNUNET_CHAT_FLAG_REFRESH,
+ NULL
+ );
+}
+
void
on_handle_gnunet_identity (void *cls,
struct GNUNET_IDENTITY_Ego *ego,
@@ -349,12 +367,12 @@ skip_account:
account_update_directory(accounts->account, handle->directory);
send_refresh:
- handle_send_internal_message(
- handle,
- NULL,
- NULL,
- GNUNET_CHAT_FLAG_REFRESH,
- NULL
+ if (handle->refresh)
+ return;
+
+ handle->refresh = GNUNET_SCHEDULER_add_now(
+ on_handle_refresh,
+ handle
);
}