reconnect (struct GNUNET_DV_ServiceHandle *sh);
+/**
+ * Start sending messages from our queue to the service.
+ *
+ * @param sh service handle
+ */
+static void
+start_transmit (struct GNUNET_DV_ServiceHandle *sh);
+
+
/**
* Gives a message from our queue to the DV service.
*
ret += tsize;
if (NULL != th->cb)
{
- GNUNET_CONTAINER_DLL_insert (th->target->head,
- th->target->tail,
- th);
+ GNUNET_CONTAINER_DLL_insert_tail (th->target->head,
+ th->target->tail,
+ th);
}
else
{
GNUNET_free (th);
}
}
+ if (NULL != sh->th_head)
+ start_transmit (sh);
return ret;
}
reconnect (sh);
return;
}
+ if (NULL ==
+ GNUNET_CONTAINER_multipeermap_get (sh->peers,
+ &rm->sender))
+ {
+ GNUNET_break (0);
+ reconnect (sh);
+ return;
+ }
sh->message_cb (sh->cls,
&rm->sender,
ntohl (rm->distance),
peer = GNUNET_CONTAINER_multipeermap_get (sh->peers,
&ack->target);
if (NULL == peer)
- return; /* this happens, just ignore */
+ break; /* this happens, just ignore */
for (th = peer->head; NULL != th; th = th->next)
{
if (th->uid != ntohl (ack->uid))
reconnect (sh);
break;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received message, continuing receive loop for %p\n",
+ sh->client);
GNUNET_CLIENT_receive (sh->client,
&handle_message_receipt, sh,
GNUNET_TIME_UNIT_FOREVER_REL);
start_message.size = htons (sizeof (struct GNUNET_MessageHeader));
start_message.type = htons (GNUNET_MESSAGE_TYPE_DV_START);
memcpy (buf, &start_message, sizeof (start_message));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting START request, starting receive loop for %p\n",
+ sh->client);
GNUNET_CLIENT_receive (sh->client,
&handle_message_receipt, sh,
GNUNET_TIME_UNIT_FOREVER_REL);
GNUNET_CLIENT_notify_transmit_ready_cancel (sh->th);
sh->th = NULL;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from DV service at %p\n",
+ sh->client);
if (NULL != sh->client)
{
GNUNET_CLIENT_disconnect (sh->client);
return NULL;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to send %u bytes of type %u to %s\n",
+ "Asked to send %u bytes of type %u to %s via %p\n",
(unsigned int) ntohs (msg->size),
(unsigned int) ntohs (msg->type),
- GNUNET_i2s (target));
+ GNUNET_i2s (target),
+ sh->client);
peer = GNUNET_CONTAINER_multipeermap_get (sh->peers,
target);
if (NULL == peer)
/* use memcpy here as 'target' may not be sufficiently aligned */
memcpy (&sm->target, target, sizeof (struct GNUNET_PeerIdentity));
memcpy (&sm[1], msg, ntohs (msg->size));
- GNUNET_CONTAINER_DLL_insert (sh->th_head,
- sh->th_tail,
- th);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->th_head,
+ sh->th_tail,
+ th);
start_transmit (sh);
return th;
}