GCPP_2s (path));
path->hn = NULL;
entry = path->entries[path->entries_length - 1];
+ GNUNET_assert (path == entry->path);
while (1)
{
/* cut 'off' end of path */
/* see if new peer at the end likes this path any better */
entry = path->entries[path->entries_length - 1];
+ GNUNET_assert (path == entry->path);
path->hn = GCP_attach_path (entry->peer,
path,
path->entries_length - 1,
int force)
{
unsigned int old_len = path->entries_length;
- struct GNUNET_CONTAINER_HeapNode *hn;
int i;
/* Expand path */
/* If we extend an existing path, detach it from the
old owner and re-attach to the new one */
- hn = NULL;
+ GCP_detach_path (path->entries[old_len-1]->peer,
+ path,
+ path->hn);
+ path->hn = NULL;
for (i=num_peers-1;i>=0;i--)
{
struct CadetPeerPathEntry *entry = path->entries[old_len + i];
path->entries_length = old_len + i + 1;
recalculate_path_desirability (path);
- hn = GCP_attach_path (peers[i],
- path,
- old_len + (unsigned int) i,
- GNUNET_YES);
- if (NULL != hn)
+ path->hn = GCP_attach_path (peers[i],
+ path,
+ old_len + (unsigned int) i,
+ GNUNET_NO);
+ if (NULL != path->hn)
break;
GCP_path_entry_remove (entry->peer,
entry,
GNUNET_free (entry);
path->entries[old_len + i] = NULL;
}
- if (NULL == hn)
+ if (NULL == path->hn)
{
/* none of the peers is interested in this path;
- shrink path back */
+ shrink path back and re-attach. */
GNUNET_array_grow (path->entries,
path->entries_length,
old_len);
+ path->hn = GCP_attach_path (path->entries[old_len - 1]->peer,
+ path,
+ old_len - 1,
+ GNUNET_YES);
+ GNUNET_assert (NULL != path->hn);
return;
}
- GCP_detach_path (path->entries[old_len-1]->peer,
- path,
- path->hn);
- path->hn = hn;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Extended path %s\n",
GCPP_2s (path));
GNUNET_CONTAINER_HeapCostType root_desirability;
struct GNUNET_CONTAINER_HeapNode *hn;
+ GNUNET_assert (off == GCPP_get_length (path) - 1);
GNUNET_assert (cp == GCPP_get_peer_at_offset (path,
off));
if (NULL == cp->path_heap)
GCPP_get_length (root) - 1)) )
{
/* Got plenty of paths to this destination, and this is a low-quality
- one that we don't care, allow it to die. */
+ one that we don't care about. Allow it to die. */
GNUNET_assert (root ==
GNUNET_CONTAINER_heap_remove_root (cp->path_heap));
GCPP_release (root);