summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-04-09 18:57:14 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2022-04-09 18:57:14 +0200
commit06f96b363afc7b1501c976bb54229973939da4d3 (patch)
tree87b79c35978ddefc9249cd3c83ab5b4f4879cda6
parent4423dd264ef99fe9617e5d871857d15e88639f51 (diff)
Fixed queued identity operation handling on stop call
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/gnunet_chat_handle.c6
-rw-r--r--src/gnunet_chat_handle.h2
-rw-r--r--src/gnunet_chat_handle_intern.c2
-rw-r--r--src/gnunet_chat_lib.c14
-rw-r--r--src/gnunet_chat_lib_intern.c4
-rw-r--r--src/gnunet_chat_lobby.c20
-rw-r--r--src/gnunet_chat_util.c31
-rw-r--r--src/gnunet_chat_util.h11
8 files changed, 82 insertions, 8 deletions
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
index 05c0054..80ade04 100644
--- a/src/gnunet_chat_handle.c
+++ b/src/gnunet_chat_handle.c
@@ -416,6 +416,8 @@ handle_create_account (struct GNUNET_CHAT_Handle *handle,
return GNUNET_SYSERR;
}
+ accounts->wait_for_completion = GNUNET_NO;
+
GNUNET_CONTAINER_DLL_insert_tail(
handle->accounts_head,
handle->accounts_tail,
@@ -464,6 +466,8 @@ handle_delete_account (struct GNUNET_CHAT_Handle *handle,
return GNUNET_SYSERR;
}
+ accounts->wait_for_completion = GNUNET_YES;
+
GNUNET_CONTAINER_DLL_insert_tail(
handle->accounts_head,
handle->accounts_tail,
@@ -483,6 +487,8 @@ handle_delete_account (struct GNUNET_CHAT_Handle *handle,
accounts
);
+ accounts->wait_for_completion = GNUNET_YES;
+
return (accounts->op? GNUNET_OK : GNUNET_SYSERR);
}
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
index 37a6faf..804b8ad 100644
--- a/src/gnunet_chat_handle.h
+++ b/src/gnunet_chat_handle.h
@@ -60,6 +60,8 @@ struct GNUNET_CHAT_InternalAccounts
struct GNUNET_CHAT_Handle *handle;
struct GNUNET_IDENTITY_Operation *op;
+ int wait_for_completion;
+
struct GNUNET_CHAT_InternalAccounts *next;
struct GNUNET_CHAT_InternalAccounts *prev;
};
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index 08b7cfd..a026617 100644
--- a/src/gnunet_chat_handle_intern.c
+++ b/src/gnunet_chat_handle_intern.c
@@ -297,6 +297,8 @@ skip_account:
accounts->handle = handle;
accounts->op = NULL;
+ accounts->wait_for_completion = GNUNET_NO;
+
if (handle->directory)
account_update_directory(accounts->account, handle->directory);
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 8c7558d..35de7dc 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -88,7 +88,12 @@ GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle,
if ((!handle) || (handle->destruction) || (!name))
return GNUNET_SYSERR;
- return handle_create_account(handle, name);
+ char *low = util_get_lower(name);
+
+ int result = handle_create_account(handle, low);
+
+ GNUNET_free(low);
+ return result;
}
@@ -206,7 +211,12 @@ GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
if (!name)
return GNUNET_NO;
- return GNUNET_MESSENGER_set_name(handle->messenger, name);
+ char *low = util_get_lower(name);
+
+ int result = GNUNET_MESSENGER_set_name(handle->messenger, name);
+
+ GNUNET_free(low);
+ return result;
}
diff --git a/src/gnunet_chat_lib_intern.c b/src/gnunet_chat_lib_intern.c
index b9806a9..eaea196 100644
--- a/src/gnunet_chat_lib_intern.c
+++ b/src/gnunet_chat_lib_intern.c
@@ -34,7 +34,7 @@ task_handle_destruction (void *cls)
struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head;
while (accounts)
{
- if ((accounts->op) && (accounts->account))
+ if ((accounts->op) && (GNUNET_YES == accounts->wait_for_completion))
break;
accounts = accounts->next;
@@ -45,7 +45,7 @@ task_handle_destruction (void *cls)
handle->destruction = GNUNET_SCHEDULER_add_at_with_priority(
GNUNET_TIME_absolute_add(
GNUNET_TIME_absolute_get(),
- GNUNET_TIME_relative_get_second_()
+ GNUNET_TIME_relative_get_millisecond_()
),
GNUNET_SCHEDULER_PRIORITY_IDLE,
task_handle_destruction,
diff --git a/src/gnunet_chat_lobby.c b/src/gnunet_chat_lobby.c
index c6d0327..4887ad8 100644
--- a/src/gnunet_chat_lobby.c
+++ b/src/gnunet_chat_lobby.c
@@ -53,6 +53,26 @@ lobby_destroy (struct GNUNET_CHAT_Lobby *lobby)
{
GNUNET_assert(lobby);
+ if ((!(lobby->op)) && (!(lobby->query)))
+ goto skip_deletion;
+
+ if (lobby->context)
+ {
+ const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
+ lobby->context->room
+ );
+
+ if (!key)
+ goto skip_deletion;
+
+ char *name;
+ util_lobby_name(key, &name);
+
+ handle_delete_account(lobby->handle, name);
+ GNUNET_free(name);
+ }
+
+skip_deletion:
if (lobby->op)
GNUNET_IDENTITY_cancel(lobby->op);
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
index de17e0c..26d2985 100644
--- a/src/gnunet_chat_util.c
+++ b/src/gnunet_chat_util.c
@@ -287,6 +287,19 @@ util_get_filename (const char *directory,
return result;
}
+char*
+util_get_lower(const char *name)
+{
+ GNUNET_assert(name);
+
+ char *lower = GNUNET_malloc(strlen(name));
+ if (GNUNET_OK == GNUNET_STRINGS_utf8_tolower(name, lower))
+ return lower;
+
+ GNUNET_free(lower);
+ return GNUNET_strdup(name);
+}
+
int
util_get_context_label (enum GNUNET_CHAT_ContextType type,
const struct GNUNET_HashCode *hash,
@@ -306,21 +319,31 @@ util_get_context_label (enum GNUNET_CHAT_ContextType type,
break;
}
- return GNUNET_asprintf (
+ char *low = util_get_lower(GNUNET_h2s(hash));
+
+ int result = GNUNET_asprintf (
label,
"%s_%s",
type_string,
- GNUNET_h2s(hash)
+ low
);
+
+ GNUNET_free(low);
+ return result;
}
int
util_lobby_name (const struct GNUNET_HashCode *hash,
char **name)
{
- return GNUNET_asprintf (
+ char *low = util_get_lower(GNUNET_h2s(hash));
+
+ int result = GNUNET_asprintf (
name,
"chat_lobby_%s",
- GNUNET_h2s(hash)
+ low
);
+
+ GNUNET_free(low);
+ return result;
}
diff --git a/src/gnunet_chat_util.h b/src/gnunet_chat_util.h
index 55f13de..8845eab 100644
--- a/src/gnunet_chat_util.h
+++ b/src/gnunet_chat_util.h
@@ -149,6 +149,17 @@ util_get_filename (const char *directory,
char **filename);
/**
+ * Allocates a new string representing the lower case versionn
+ * of a given <i>name</i> to work properly with the EGO naming
+ * scheme for example.
+ *
+ * @param[in] name Name
+ * @return Lower case name
+ */
+char*
+util_get_lower(const char *name);
+
+/**
* Construct a composed <i>label</i> from a given context
* <i>type</i> and the <i>hash</i> of the contexts room.
*