aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-03-19 16:48:52 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-03-19 16:48:52 +0100
commit7293cd91dfa15e290d01952b4f4d51fe6ec46f25 (patch)
tree98bfaa8e2e91e1695ca0232b6596120ec18c8cd4
parent89d4e01123cc5d9130f6b0a20591081ddb66288d (diff)
downloadlibgnunetchat-7293cd91dfa15e290d01952b4f4d51fe6ec46f25.tar.gz
libgnunetchat-7293cd91dfa15e290d01952b4f4d51fe6ec46f25.zip
Cleanup namestore operations
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/gnunet_chat_context.c22
-rw-r--r--src/gnunet_chat_context.h3
-rw-r--r--src/gnunet_chat_context_intern.c22
3 files changed, 43 insertions, 4 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c
index e0d7082..be3dd4a 100644
--- a/src/gnunet_chat_context.c
+++ b/src/gnunet_chat_context.c
@@ -57,6 +57,9 @@ context_create_from_room (struct GNUNET_CHAT_Handle *handle,
57 8, GNUNET_NO 57 8, GNUNET_NO
58 ); 58 );
59 59
60 context->query_open = NULL;
61 context->query_commit = NULL;
62
60 return context; 63 return context;
61} 64}
62 65
@@ -88,6 +91,9 @@ context_create_from_contact (struct GNUNET_CHAT_Handle *handle,
88 8, GNUNET_NO 91 8, GNUNET_NO
89 ); 92 );
90 93
94 context->query_open = NULL;
95 context->query_commit = NULL;
96
91 return context; 97 return context;
92} 98}
93 99
@@ -100,6 +106,12 @@ context_destroy (struct GNUNET_CHAT_Context *context)
100 (context->invites) && 106 (context->invites) &&
101 (context->files)); 107 (context->files));
102 108
109 if (context->query_open)
110 GNUNET_NAMESTORE_cancel(context->query_open);
111
112 if (context->query_commit)
113 GNUNET_NAMESTORE_cancel(context->query_commit);
114
103 GNUNET_CONTAINER_multishortmap_iterate( 115 GNUNET_CONTAINER_multishortmap_iterate(
104 context->timestamps, it_destroy_context_timestamps, NULL 116 context->timestamps, it_destroy_context_timestamps, NULL
105 ); 117 );
@@ -272,7 +284,10 @@ context_write_records (struct GNUNET_CHAT_Context *context)
272 char *label; 284 char *label;
273 util_get_context_label(context->type, hash, &label); 285 util_get_context_label(context->type, hash, &label);
274 286
275 GNUNET_NAMESTORE_records_open( 287 if (context->query_open)
288 GNUNET_NAMESTORE_cancel(context->query_open);
289
290 context->query_open = GNUNET_NAMESTORE_records_open(
276 context->handle->namestore, 291 context->handle->namestore,
277 zone, 292 zone,
278 label, 293 label,
@@ -306,7 +321,10 @@ context_delete_records (struct GNUNET_CHAT_Context *context)
306 char *label; 321 char *label;
307 util_get_context_label(context->type, hash, &label); 322 util_get_context_label(context->type, hash, &label);
308 323
309 GNUNET_NAMESTORE_records_open( 324 if (context->query_open)
325 GNUNET_NAMESTORE_cancel(context->query_open);
326
327 context->query_open = GNUNET_NAMESTORE_records_open(
310 context->handle->namestore, 328 context->handle->namestore,
311 zone, 329 zone,
312 label, 330 label,
diff --git a/src/gnunet_chat_context.h b/src/gnunet_chat_context.h
index 37d9bc8..f2e41d0 100644
--- a/src/gnunet_chat_context.h
+++ b/src/gnunet_chat_context.h
@@ -56,6 +56,9 @@ struct GNUNET_CHAT_Context
56 void *user_pointer; 56 void *user_pointer;
57 57
58 struct GNUNET_CONTAINER_MultiShortmap *member_pointers; 58 struct GNUNET_CONTAINER_MultiShortmap *member_pointers;
59
60 struct GNUNET_NAMESTORE_QueueEntry *query_open;
61 struct GNUNET_NAMESTORE_QueueEntry *query_commit;
59}; 62};
60 63
61struct GNUNET_CHAT_Context* 64struct GNUNET_CHAT_Context*
diff --git a/src/gnunet_chat_context_intern.c b/src/gnunet_chat_context_intern.c
index 79c09a2..af1e2cc 100644
--- a/src/gnunet_chat_context_intern.c
+++ b/src/gnunet_chat_context_intern.c
@@ -70,6 +70,10 @@ cont_context_commit_records (void *cls,
70{ 70{
71 struct GNUNET_CHAT_Context *context = cls; 71 struct GNUNET_CHAT_Context *context = cls;
72 72
73 GNUNET_assert(context);
74
75 context->query_commit = NULL;
76
73 if ((!emsg) || (!(context->handle))) 77 if ((!emsg) || (!(context->handle)))
74 return; 78 return;
75 79
@@ -86,6 +90,10 @@ error_context_open_records (void *cls)
86{ 90{
87 struct GNUNET_CHAT_Context *context = cls; 91 struct GNUNET_CHAT_Context *context = cls;
88 92
93 GNUNET_assert(context);
94
95 context->query_open = NULL;
96
89 if (!(context->handle)) 97 if (!(context->handle))
90 return; 98 return;
91 99
@@ -108,6 +116,8 @@ monitor_context_open_records (void *cls,
108 116
109 GNUNET_assert((context) && (context->handle)); 117 GNUNET_assert((context) && (context->handle));
110 118
119 context->query_open = NULL;
120
111 const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key( 121 const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key(
112 context->room 122 context->room
113 ); 123 );
@@ -172,7 +182,10 @@ monitor_context_open_records (void *cls,
172 count++; 182 count++;
173 } 183 }
174 184
175 GNUNET_NAMESTORE_records_commit( 185 if (context->query_commit)
186 GNUNET_NAMESTORE_cancel(context->query_commit);
187
188 context->query_commit = GNUNET_NAMESTORE_records_commit(
176 context->handle->namestore, 189 context->handle->namestore,
177 zone, 190 zone,
178 label, 191 label,
@@ -194,7 +207,12 @@ monitor_context_delete_records (void *cls,
194 207
195 GNUNET_assert((context) && (context->handle)); 208 GNUNET_assert((context) && (context->handle));
196 209
197 GNUNET_NAMESTORE_records_commit( 210 context->query_open = NULL;
211
212 if (context->query_commit)
213 GNUNET_NAMESTORE_cancel(context->query_commit);
214
215 context->query_commit = GNUNET_NAMESTORE_records_commit(
198 context->handle->namestore, 216 context->handle->namestore,
199 zone, 217 zone,
200 label, 218 label,