aboutsummaryrefslogtreecommitdiff
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)
downloadlibgnunetchat-06f96b363afc7b1501c976bb54229973939da4d3.tar.gz
libgnunetchat-06f96b363afc7b1501c976bb54229973939da4d3.zip
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,
416 return GNUNET_SYSERR; 416 return GNUNET_SYSERR;
417 } 417 }
418 418
419 accounts->wait_for_completion = GNUNET_NO;
420
419 GNUNET_CONTAINER_DLL_insert_tail( 421 GNUNET_CONTAINER_DLL_insert_tail(
420 handle->accounts_head, 422 handle->accounts_head,
421 handle->accounts_tail, 423 handle->accounts_tail,
@@ -464,6 +466,8 @@ handle_delete_account (struct GNUNET_CHAT_Handle *handle,
464 return GNUNET_SYSERR; 466 return GNUNET_SYSERR;
465 } 467 }
466 468
469 accounts->wait_for_completion = GNUNET_YES;
470
467 GNUNET_CONTAINER_DLL_insert_tail( 471 GNUNET_CONTAINER_DLL_insert_tail(
468 handle->accounts_head, 472 handle->accounts_head,
469 handle->accounts_tail, 473 handle->accounts_tail,
@@ -483,6 +487,8 @@ handle_delete_account (struct GNUNET_CHAT_Handle *handle,
483 accounts 487 accounts
484 ); 488 );
485 489
490 accounts->wait_for_completion = GNUNET_YES;
491
486 return (accounts->op? GNUNET_OK : GNUNET_SYSERR); 492 return (accounts->op? GNUNET_OK : GNUNET_SYSERR);
487} 493}
488 494
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
60 struct GNUNET_CHAT_Handle *handle; 60 struct GNUNET_CHAT_Handle *handle;
61 struct GNUNET_IDENTITY_Operation *op; 61 struct GNUNET_IDENTITY_Operation *op;
62 62
63 int wait_for_completion;
64
63 struct GNUNET_CHAT_InternalAccounts *next; 65 struct GNUNET_CHAT_InternalAccounts *next;
64 struct GNUNET_CHAT_InternalAccounts *prev; 66 struct GNUNET_CHAT_InternalAccounts *prev;
65}; 67};
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:
297 accounts->handle = handle; 297 accounts->handle = handle;
298 accounts->op = NULL; 298 accounts->op = NULL;
299 299
300 accounts->wait_for_completion = GNUNET_NO;
301
300 if (handle->directory) 302 if (handle->directory)
301 account_update_directory(accounts->account, handle->directory); 303 account_update_directory(accounts->account, handle->directory);
302 304
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,
88 if ((!handle) || (handle->destruction) || (!name)) 88 if ((!handle) || (handle->destruction) || (!name))
89 return GNUNET_SYSERR; 89 return GNUNET_SYSERR;
90 90
91 return handle_create_account(handle, name); 91 char *low = util_get_lower(name);
92
93 int result = handle_create_account(handle, low);
94
95 GNUNET_free(low);
96 return result;
92} 97}
93 98
94 99
@@ -206,7 +211,12 @@ GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
206 if (!name) 211 if (!name)
207 return GNUNET_NO; 212 return GNUNET_NO;
208 213
209 return GNUNET_MESSENGER_set_name(handle->messenger, name); 214 char *low = util_get_lower(name);
215
216 int result = GNUNET_MESSENGER_set_name(handle->messenger, name);
217
218 GNUNET_free(low);
219 return result;
210} 220}
211 221
212 222
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)
34 struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; 34 struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head;
35 while (accounts) 35 while (accounts)
36 { 36 {
37 if ((accounts->op) && (accounts->account)) 37 if ((accounts->op) && (GNUNET_YES == accounts->wait_for_completion))
38 break; 38 break;
39 39
40 accounts = accounts->next; 40 accounts = accounts->next;
@@ -45,7 +45,7 @@ task_handle_destruction (void *cls)
45 handle->destruction = GNUNET_SCHEDULER_add_at_with_priority( 45 handle->destruction = GNUNET_SCHEDULER_add_at_with_priority(
46 GNUNET_TIME_absolute_add( 46 GNUNET_TIME_absolute_add(
47 GNUNET_TIME_absolute_get(), 47 GNUNET_TIME_absolute_get(),
48 GNUNET_TIME_relative_get_second_() 48 GNUNET_TIME_relative_get_millisecond_()
49 ), 49 ),
50 GNUNET_SCHEDULER_PRIORITY_IDLE, 50 GNUNET_SCHEDULER_PRIORITY_IDLE,
51 task_handle_destruction, 51 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)
53{ 53{
54 GNUNET_assert(lobby); 54 GNUNET_assert(lobby);
55 55
56 if ((!(lobby->op)) && (!(lobby->query)))
57 goto skip_deletion;
58
59 if (lobby->context)
60 {
61 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
62 lobby->context->room
63 );
64
65 if (!key)
66 goto skip_deletion;
67
68 char *name;
69 util_lobby_name(key, &name);
70
71 handle_delete_account(lobby->handle, name);
72 GNUNET_free(name);
73 }
74
75skip_deletion:
56 if (lobby->op) 76 if (lobby->op)
57 GNUNET_IDENTITY_cancel(lobby->op); 77 GNUNET_IDENTITY_cancel(lobby->op);
58 78
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,
287 return result; 287 return result;
288} 288}
289 289
290char*
291util_get_lower(const char *name)
292{
293 GNUNET_assert(name);
294
295 char *lower = GNUNET_malloc(strlen(name));
296 if (GNUNET_OK == GNUNET_STRINGS_utf8_tolower(name, lower))
297 return lower;
298
299 GNUNET_free(lower);
300 return GNUNET_strdup(name);
301}
302
290int 303int
291util_get_context_label (enum GNUNET_CHAT_ContextType type, 304util_get_context_label (enum GNUNET_CHAT_ContextType type,
292 const struct GNUNET_HashCode *hash, 305 const struct GNUNET_HashCode *hash,
@@ -306,21 +319,31 @@ util_get_context_label (enum GNUNET_CHAT_ContextType type,
306 break; 319 break;
307 } 320 }
308 321
309 return GNUNET_asprintf ( 322 char *low = util_get_lower(GNUNET_h2s(hash));
323
324 int result = GNUNET_asprintf (
310 label, 325 label,
311 "%s_%s", 326 "%s_%s",
312 type_string, 327 type_string,
313 GNUNET_h2s(hash) 328 low
314 ); 329 );
330
331 GNUNET_free(low);
332 return result;
315} 333}
316 334
317int 335int
318util_lobby_name (const struct GNUNET_HashCode *hash, 336util_lobby_name (const struct GNUNET_HashCode *hash,
319 char **name) 337 char **name)
320{ 338{
321 return GNUNET_asprintf ( 339 char *low = util_get_lower(GNUNET_h2s(hash));
340
341 int result = GNUNET_asprintf (
322 name, 342 name,
323 "chat_lobby_%s", 343 "chat_lobby_%s",
324 GNUNET_h2s(hash) 344 low
325 ); 345 );
346
347 GNUNET_free(low);
348 return result;
326} 349}
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,
149 char **filename); 149 char **filename);
150 150
151/** 151/**
152 * Allocates a new string representing the lower case versionn
153 * of a given <i>name</i> to work properly with the EGO naming
154 * scheme for example.
155 *
156 * @param[in] name Name
157 * @return Lower case name
158 */
159char*
160util_get_lower(const char *name);
161
162/**
152 * Construct a composed <i>label</i> from a given context 163 * Construct a composed <i>label</i> from a given context
153 * <i>type</i> and the <i>hash</i> of the contexts room. 164 * <i>type</i> and the <i>hash</i> of the contexts room.
154 * 165 *