aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c4
-rw-r--r--src/peerinfo/peerinfo_api.c24
2 files changed, 25 insertions, 3 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index d450bf748..de27cd276 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -679,7 +679,7 @@ static void
679add_continuation (void *cls, 679add_continuation (void *cls,
680 const char *emsg) 680 const char *emsg)
681{ 681{
682 ai = NULL; 682 ac = NULL;
683 if (NULL != emsg) 683 if (NULL != emsg)
684 fprintf (stderr, 684 fprintf (stderr,
685 _("Failure adding HELLO: %s\n"), 685 _("Failure adding HELLO: %s\n"),
@@ -723,7 +723,7 @@ parse_hello_uri (const char *put_uri)
723 { 723 {
724 /* WARNING: this adds the address from URI WITHOUT verification! */ 724 /* WARNING: this adds the address from URI WITHOUT verification! */
725 if (GNUNET_OK == ctx.ret) 725 if (GNUNET_OK == ctx.ret)
726 ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, NULL, NULL); 726 ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL);
727 else 727 else
728 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); 728 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
729 GNUNET_free (hello); 729 GNUNET_free (hello);
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index f70b8fde1..5b79a17e5 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -52,6 +52,11 @@ struct GNUNET_PEERINFO_AddContext
52 struct GNUNET_PEERINFO_AddContext *prev; 52 struct GNUNET_PEERINFO_AddContext *prev;
53 53
54 /** 54 /**
55 * Handle to the PEERINFO service.
56 */
57 struct GNUNET_PEERINFO_Handle *h;
58
59 /**
55 * Function to call after request has been transmitted, or NULL. 60 * Function to call after request has been transmitted, or NULL.
56 */ 61 */
57 GNUNET_PEERINFO_Continuation cont; 62 GNUNET_PEERINFO_Continuation cont;
@@ -420,17 +425,34 @@ GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
420 "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n", 425 "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
421 GNUNET_i2s (&peer), hs, "HELLO"); 426 GNUNET_i2s (&peer), hs, "HELLO");
422 ac = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + hs); 427 ac = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + hs);
428 ac->h = h;
423 ac->size = hs; 429 ac->size = hs;
424 ac->cont = cont; 430 ac->cont = cont;
425 ac->cont_cls = cont_cls; 431 ac->cont_cls = cont_cls;
426 memcpy (&ac[1], hello, hs); 432 memcpy (&ac[1], hello, hs);
427 GNUNET_CONTAINER_DLL_insert_after (h->ac_head, h->ac_tail, h->ac_tail, ac); 433 GNUNET_CONTAINER_DLL_insert_tail (h->ac_head, h->ac_tail, ac);
428 trigger_transmit (h); 434 trigger_transmit (h);
429 return ac; 435 return ac;
430} 436}
431 437
432 438
433/** 439/**
440 * Cancel pending 'add' operation. Must only be called before
441 * either 'cont' or 'GNUNET_PEERINFO_disconnect' are invoked.
442 *
443 * @param ac handle for the add operation to cancel
444 */
445void
446GNUNET_PEERINFO_add_peer_cancel (struct GNUNET_PEERINFO_AddContext *ac)
447{
448 struct GNUNET_PEERINFO_Handle *h = ac->h;
449
450 GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
451 GNUNET_free (ac);
452}
453
454
455/**
434 * Type of a function to call when we receive a message from the 456 * Type of a function to call when we receive a message from the
435 * service. Call the iterator with the result and (if applicable) 457 * service. Call the iterator with the result and (if applicable)
436 * continue to receive more messages or trigger processing the next 458 * continue to receive more messages or trigger processing the next