/*
This file is part of GNUnet.
- (C) 2009--2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009--2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
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.
*
- * @param cls handle to the dv service (struct GNUNET_DV_ServiceHandle)
+ * @param cls handle to the dv service (`struct GNUNET_DV_ServiceHandle`)
* @param size how many bytes can we send
* @param buf where to copy the message to send
* @return how many bytes we copied to @a buf
sh->th_tail,
th);
memcpy (&cbuf[ret], th->msg, tsize);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Passing %u bytes of type %u to DV service\n",
+ tsize,
+ ntohs (th->msg->type));
th->msg = NULL;
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;
}