commit 296e5f5846c60f1419309f452fdac2cad2a8b133
parent a2a3cd3a8cd4e537fbbc8e072428b621c2683027
Author: Jacki <jacki@thejackimonster.de>
Date: Sun, 6 Oct 2024 00:09:44 +0200
Fix refresh message and attribute sharing test case
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
5 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
@@ -92,6 +92,8 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
handle->accounts_head = NULL;
handle->accounts_tail = NULL;
+ handle->refreshing = GNUNET_NO;
+
handle->next = NULL;
handle->current = NULL;
handle->monitor = NULL;
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
@@ -106,6 +106,8 @@ struct GNUNET_CHAT_Handle
struct GNUNET_CHAT_InternalAccounts *accounts_head;
struct GNUNET_CHAT_InternalAccounts *accounts_tail;
+ enum GNUNET_GenericReturnValue refreshing;
+
struct GNUNET_CHAT_Account *next;
struct GNUNET_CHAT_Account *current;
struct GNUNET_NAMESTORE_ZoneMonitor *monitor;
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -312,7 +312,10 @@ on_handle_gnunet_identity (void *cls,
struct GNUNET_CHAT_Handle* handle = cls;
if ((!ctx) || (!ego))
+ {
+ handle->refreshing = GNUNET_YES;
goto send_refresh;
+ }
struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head;
@@ -372,11 +375,12 @@ skip_account:
);
send_refresh:
- if (handle->refresh)
+ if ((GNUNET_YES != handle->refreshing) ||
+ (handle->refresh))
return;
handle->refresh = GNUNET_SCHEDULER_add_with_priority(
- GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
on_handle_refresh,
handle
);
diff --git a/tests/attribute/test_gnunet_chat_attribute_share.c b/tests/attribute/test_gnunet_chat_attribute_share.c
@@ -145,15 +145,19 @@ on_gnunet_chat_attribute_share_msg(void *cls,
ck_assert_ptr_nonnull(name);
- if (share_stage < 4)
- share_stage = 4;
-
if (0 == strcmp(name, TEST_SHARE_ID_A))
- break;
+ {
+ ck_assert_uint_eq(share_stage, 3);
+
+ share_stage = 4;
+ }
+ else if (0 == strcmp(name, TEST_SHARE_ID_B))
+ {
+ ck_assert_uint_eq(share_stage, 7);
- ck_assert_uint_eq(share_stage, 7);
+ GNUNET_CHAT_stop(handle);
+ }
- GNUNET_CHAT_stop(handle);
break;
case GNUNET_CHAT_KIND_UPDATE_ACCOUNT:
ck_assert_ptr_nonnull(account);
diff --git a/tests/test_gnunet_chat.h b/tests/test_gnunet_chat.h
@@ -55,6 +55,9 @@ on_setup_##test_call (void *cls, \
account = GNUNET_CHAT_message_get_account(message); \
ck_assert_ptr_nonnull(account); \
\
+ fprintf(stdout, " - Setup account: %s\n", \
+ GNUNET_CHAT_account_get_name(account)); \
+ \
const char **accounts; \
for (accounts = test_accounts; *accounts; accounts++) \
if (0 == strcmp(GNUNET_CHAT_account_get_name(account), \
@@ -116,6 +119,9 @@ on_cleanup_##test_call (void *cls, \
account = GNUNET_CHAT_message_get_account(message); \
ck_assert_ptr_nonnull(account); \
\
+ fprintf(stdout, " - Cleanup account: %s\n", \
+ GNUNET_CHAT_account_get_name(account)); \
+ \
const char **accounts; \
for (accounts = test_accounts; *accounts; accounts++) \
if (0 == strcmp(GNUNET_CHAT_account_get_name(account), \