aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/escrow_api.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-08-06 12:51:27 +0200
committerjospaeth <spaethj@in.tum.de>2020-08-06 12:51:27 +0200
commit8c3c9d1ae8086a8498b0e5159b8168fb47bf50e0 (patch)
tree5963fe1172e4fb78fb259a2036aa66f43e3eeb24 /src/escrow/escrow_api.c
parente35aa4c6b22ae0ae81a23e973eda3655f29e29b5 (diff)
downloadgnunet-8c3c9d1ae8086a8498b0e5159b8168fb47bf50e0.tar.gz
gnunet-8c3c9d1ae8086a8498b0e5159b8168fb47bf50e0.zip
clean up plugin operations
Diffstat (limited to 'src/escrow/escrow_api.c')
-rw-r--r--src/escrow/escrow_api.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c
index 446833758..ff1943f06 100644
--- a/src/escrow/escrow_api.c
+++ b/src/escrow/escrow_api.c
@@ -142,6 +142,8 @@ GNUNET_ESCROW_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
142void 142void
143GNUNET_ESCROW_fini (struct GNUNET_ESCROW_Handle *h) 143GNUNET_ESCROW_fini (struct GNUNET_ESCROW_Handle *h)
144{ 144{
145 struct GNUNET_ESCROW_Operation *op;
146
145 /* unload all loaded plugins */ 147 /* unload all loaded plugins */
146 if (GNUNET_YES == plaintext_initialized) 148 if (GNUNET_YES == plaintext_initialized)
147 { 149 {
@@ -170,7 +172,14 @@ GNUNET_ESCROW_fini (struct GNUNET_ESCROW_Handle *h)
170 anastasis_api = NULL; 172 anastasis_api = NULL;
171 } 173 }
172 174
173 /* freee the escrow handle */ 175 /* clean up the operation DLL */
176 while (NULL != (op = h->op_head))
177 {
178 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
179 GNUNET_ESCROW_cancel (op);
180 }
181
182 /* free the escrow handle */
174 GNUNET_free (h); 183 GNUNET_free (h);
175} 184}
176 185
@@ -193,7 +202,7 @@ handle_start_escrow_result (void *cls)
193 } 202 }
194 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op); 203 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op);
195 if (NULL != op->cb_put) 204 if (NULL != op->cb_put)
196 op->cb_put (w->escrowAnchor); 205 op->cb_put (op->cb_cls, w->escrowAnchor);
197 GNUNET_free (op); 206 GNUNET_free (op);
198 GNUNET_free (w); 207 GNUNET_free (w);
199} 208}
@@ -206,6 +215,7 @@ handle_start_escrow_result (void *cls)
206 * @param ego the identity ego to put in escrow 215 * @param ego the identity ego to put in escrow
207 * @param method the escrow method to use 216 * @param method the escrow method to use
208 * @param cb function to call with the escrow anchor on completion 217 * @param cb function to call with the escrow anchor on completion
218 * @param cb_cls closure for @a cb
209 * 219 *
210 * @return handle to abort the operation 220 * @return handle to abort the operation
211 */ 221 */
@@ -213,7 +223,8 @@ struct GNUNET_ESCROW_Operation *
213GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h, 223GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h,
214 const struct GNUNET_IDENTITY_Ego *ego, 224 const struct GNUNET_IDENTITY_Ego *ego,
215 enum GNUNET_ESCROW_Key_Escrow_Method method, 225 enum GNUNET_ESCROW_Key_Escrow_Method method,
216 GNUNET_ESCROW_AnchorContinuation cb) 226 GNUNET_ESCROW_AnchorContinuation cb,
227 void *cb_cls)
217{ 228{
218 struct GNUNET_ESCROW_Operation *op; 229 struct GNUNET_ESCROW_Operation *op;
219 const struct GNUNET_ESCROW_KeyPluginFunctions *api; 230 const struct GNUNET_ESCROW_KeyPluginFunctions *api;
@@ -222,6 +233,7 @@ GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h,
222 op->h = h; 233 op->h = h;
223 op->method = method; 234 op->method = method;
224 op->cb_put = cb; 235 op->cb_put = cb;
236 op->cb_cls = cb_cls;
225 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 237 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
226 238
227 api = init_plugin (h, method); 239 api = init_plugin (h, method);
@@ -249,7 +261,7 @@ handle_restore_key_result (void *cls)
249 } 261 }
250 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op); 262 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op);
251 if (NULL != op->cb_get) 263 if (NULL != op->cb_get)
252 op->cb_get (w->ego); 264 op->cb_get (op->cb_cls, w->ego);
253 GNUNET_free (op); 265 GNUNET_free (op);
254 GNUNET_free (w); 266 GNUNET_free (w);
255} 267}
@@ -263,6 +275,7 @@ handle_restore_key_result (void *cls)
263 * @param egoName the name of the ego to get back 275 * @param egoName the name of the ego to get back
264 * @param method the escrow method to use 276 * @param method the escrow method to use
265 * @param cb function to call with the restored ego on completion 277 * @param cb function to call with the restored ego on completion
278 * @param cb_cls closure for @a cb
266 * 279 *
267 * @return handle to abort the operation 280 * @return handle to abort the operation
268 */ 281 */
@@ -271,7 +284,8 @@ GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
271 struct GNUNET_ESCROW_Anchor *escrowAnchor, 284 struct GNUNET_ESCROW_Anchor *escrowAnchor,
272 char *egoName, 285 char *egoName,
273 enum GNUNET_ESCROW_Key_Escrow_Method method, 286 enum GNUNET_ESCROW_Key_Escrow_Method method,
274 GNUNET_ESCROW_EgoContinuation cb) 287 GNUNET_ESCROW_EgoContinuation cb,
288 void *cb_cls)
275{ 289{
276 struct GNUNET_ESCROW_Operation *op; 290 struct GNUNET_ESCROW_Operation *op;
277 const struct GNUNET_ESCROW_KeyPluginFunctions *api; 291 const struct GNUNET_ESCROW_KeyPluginFunctions *api;
@@ -280,6 +294,7 @@ GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
280 op->h = h; 294 op->h = h;
281 op->method = method; 295 op->method = method;
282 op->cb_get = cb; 296 op->cb_get = cb;
297 op->cb_cls = cb_cls;
283 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 298 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
284 299
285 api = init_plugin (h, method); 300 api = init_plugin (h, method);
@@ -307,7 +322,7 @@ handle_verify_escrow_result (void *cls)
307 } 322 }
308 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op); 323 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op);
309 if (NULL != op->cb_verify) 324 if (NULL != op->cb_verify)
310 op->cb_verify (w->verificationResult); 325 op->cb_verify (op->cb_cls, w->verificationResult);
311 GNUNET_free (op->plugin_op_wrap->plugin_op); 326 GNUNET_free (op->plugin_op_wrap->plugin_op);
312 GNUNET_free (op->plugin_op_wrap); 327 GNUNET_free (op->plugin_op_wrap);
313 GNUNET_free (op); 328 GNUNET_free (op);
@@ -323,6 +338,7 @@ handle_verify_escrow_result (void *cls)
323 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method 338 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method
324 * @param method the escrow method to use 339 * @param method the escrow method to use
325 * @param cb function to call with the verification result on completion 340 * @param cb function to call with the verification result on completion
341 * @param cb_cls closure for @a cb
326 * 342 *
327 * @return handle to abort the operation 343 * @return handle to abort the operation
328 */ 344 */
@@ -331,7 +347,8 @@ GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h,
331 const struct GNUNET_IDENTITY_Ego *ego, 347 const struct GNUNET_IDENTITY_Ego *ego,
332 struct GNUNET_ESCROW_Anchor *escrowAnchor, 348 struct GNUNET_ESCROW_Anchor *escrowAnchor,
333 enum GNUNET_ESCROW_Key_Escrow_Method method, 349 enum GNUNET_ESCROW_Key_Escrow_Method method,
334 GNUNET_ESCROW_VerifyContinuation cb) 350 GNUNET_ESCROW_VerifyContinuation cb,
351 void *cb_cls)
335{ 352{
336 struct GNUNET_ESCROW_Operation *op; 353 struct GNUNET_ESCROW_Operation *op;
337 const struct GNUNET_ESCROW_KeyPluginFunctions *api; 354 const struct GNUNET_ESCROW_KeyPluginFunctions *api;
@@ -340,6 +357,7 @@ GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h,
340 op->h = h; 357 op->h = h;
341 op->method = method; 358 op->method = method;
342 op->cb_verify = cb; 359 op->cb_verify = cb;
360 op->cb_cls = cb_cls;
343 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 361 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
344 362
345 api = init_plugin (h, method); 363 api = init_plugin (h, method);
@@ -427,25 +445,14 @@ void
427GNUNET_ESCROW_cancel (struct GNUNET_ESCROW_Operation *op) 445GNUNET_ESCROW_cancel (struct GNUNET_ESCROW_Operation *op)
428{ 446{
429 const struct GNUNET_ESCROW_KeyPluginFunctions *api; 447 const struct GNUNET_ESCROW_KeyPluginFunctions *api;
430 struct GNUNET_ESCROW_Handle *h = op->h;
431 struct GNUNET_ESCROW_Operation *curr;
432 448
433 // check if op is in our DLL 449 api = init_plugin (op->h, op->method);
434 for (curr = h->op_head; NULL != curr; curr = curr->next) 450 api->cancel_plugin_operation (op->plugin_op_wrap);
435 { 451 // TODO: check which callback is not NULL?
436 if (curr == op) 452 op->cb_put = NULL;
437 { 453 op->cb_verify = NULL;
438 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 454 op->cb_get = NULL;
439 api = init_plugin (op->h, op->method); 455 GNUNET_free (op);
440 api->cancel_plugin_operation (op->plugin_op_wrap);
441 // TODO: check which callback is not NULL?
442 op->cb_put = NULL;
443 op->cb_verify = NULL;
444 op->cb_get = NULL;
445 GNUNET_free (op);
446 return;
447 }
448 }
449} 456}
450 457
451 458