add_continuation (void *cls,
const char *emsg)
{
- ai = NULL;
+ ac = NULL;
if (NULL != emsg)
fprintf (stderr,
_("Failure adding HELLO: %s\n"),
{
/* WARNING: this adds the address from URI WITHOUT verification! */
if (GNUNET_OK == ctx.ret)
- ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, NULL, NULL);
+ ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL);
else
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
GNUNET_free (hello);
*/
struct GNUNET_PEERINFO_AddContext *prev;
+ /**
+ * Handle to the PEERINFO service.
+ */
+ struct GNUNET_PEERINFO_Handle *h;
+
/**
* Function to call after request has been transmitted, or NULL.
*/
"Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
GNUNET_i2s (&peer), hs, "HELLO");
ac = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + hs);
+ ac->h = h;
ac->size = hs;
ac->cont = cont;
ac->cont_cls = cont_cls;
memcpy (&ac[1], hello, hs);
- GNUNET_CONTAINER_DLL_insert_after (h->ac_head, h->ac_tail, h->ac_tail, ac);
+ GNUNET_CONTAINER_DLL_insert_tail (h->ac_head, h->ac_tail, ac);
trigger_transmit (h);
return ac;
}
+/**
+ * Cancel pending 'add' operation. Must only be called before
+ * either 'cont' or 'GNUNET_PEERINFO_disconnect' are invoked.
+ *
+ * @param ac handle for the add operation to cancel
+ */
+void
+GNUNET_PEERINFO_add_peer_cancel (struct GNUNET_PEERINFO_AddContext *ac)
+{
+ struct GNUNET_PEERINFO_Handle *h = ac->h;
+
+ GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
+ GNUNET_free (ac);
+}
+
+
/**
* Type of a function to call when we receive a message from the
* service. Call the iterator with the result and (if applicable)