}
-/**
- * Given a block at the given offset and depth, calculate the offset
- * for the CHK at the given index.
- *
- * @param offset the offset of the first
- * DBLOCK in the subtree of the
- * identified IBLOCK
- * @param depth the depth of the IBLOCK in the tree, 0 for DBLOCK
- * @param k which CHK in the IBLOCK are we
- * talking about
- * @return offset if k=0, otherwise an appropriately
- * larger value (i.e., if depth = 1,
- * the returned value should be offset+k*DBLOCK_SIZE)
- */
-static uint64_t
-compute_dblock_offset (uint64_t offset,
- unsigned int depth,
- unsigned int k)
-{
- unsigned int i;
- uint64_t lsize; /* what is the size of the sum of all DBlocks
- that a CHK at depth i corresponds to? */
-
- if (depth == 0)
- return offset;
- lsize = DBLOCK_SIZE;
- for (i=1;i<depth;i++)
- lsize *= CHK_PER_INODE;
- return offset + k * lsize;
-}
-
-
/**
* Fill in all of the generic fields for a download event and call the
* callback.
child_block_size = GNUNET_FS_tree_compute_tree_size (drc->depth);
GNUNET_assert (0 == (drc->offset - dr->offset) % child_block_size);
chk_off = (drc->offset - dr->offset) / child_block_size;
- GNUNET_assert (drc->state == BRS_INIT);
- drc->state = BRS_CHK_SET;
- drc->chk = chks[chk_off];
- try_top_down_reconstruction (dc, drc);
+ if (drc->state == BRS_INIT)
+ {
+ drc->state = BRS_CHK_SET;
+ drc->chk = chks[chk_off];
+ try_top_down_reconstruction (dc, drc);
+ }
if (drc->state != BRS_DOWNLOAD_UP)
up_done = GNUNET_NO; /* children not all done */
}
dr->depth,
GNUNET_h2s (&dr->chk.query));
#endif
- GNUNET_assert (GNUNET_NO ==
- GNUNET_CONTAINER_multihashmap_contains_value (dc->active,
- &dr->chk.query,
- dr));
+ if (GNUNET_NO !=
+ GNUNET_CONTAINER_multihashmap_contains_value (dc->active,
+ &dr->chk.query,
+ dr))
+ return; /* already active */
GNUNET_CONTAINER_multihashmap_put (dc->active,
&dr->chk.query,
dr,
DIR_SEPARATOR_STR,
sfn);
}
+ GNUNET_free (sfn);
GNUNET_free (dn);
}
if ( (full_name != NULL) &&
chk = (struct ContentHashKey*) pt;
for (i=(prc->size / sizeof(struct ContentHashKey))-1;i>=0;i--)
{
- off = compute_dblock_offset (dr->offset,
- dr->depth,
- i);
drc = dr->children[i];
switch (drc->state)
{
dc->th = NULL;
}
GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
+ dc->in_receive = GNUNET_NO;
dc->client = NULL;
GNUNET_FS_free_download_request_ (dc->top_request);
dc->top_request = NULL;
dc);
GNUNET_assert (dc->th != NULL);
}
+ if (GNUNET_NO == dc->in_receive)
+ {
+ dc->in_receive = GNUNET_YES;
+ GNUNET_CLIENT_receive (dc->client,
+ &receive_results,
+ dc,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ }
return msize;
}
dc);
GNUNET_assert (dc->th != NULL);
}
- GNUNET_CLIENT_receive (client,
- &receive_results,
- dc,
- GNUNET_TIME_UNIT_FOREVER_REL);
}
&retry_entry,
dc);
GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
+ dc->in_receive = GNUNET_NO;
dc->client = NULL;
}
#if DEBUG_DOWNLOAD
GNUNET_assert (dc->client == NULL);
GNUNET_assert (dc->th == NULL);
dc->client = client;
- GNUNET_CLIENT_receive (client,
- &receive_results,
- dc,
- GNUNET_TIME_UNIT_FOREVER_REL);
pi.status = GNUNET_FS_STATUS_DOWNLOAD_ACTIVE;
GNUNET_FS_download_make_status_ (&pi, dc);
- GNUNET_assert (dc->pending_head == NULL);
- GNUNET_assert (dc->pending_tail == NULL);
+ dc->pending_head = NULL;
+ dc->pending_tail = NULL;
GNUNET_CONTAINER_multihashmap_iterate (dc->active,
&retry_entry,
dc);
if (NULL != dc->client)
{
GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
+ dc->in_receive = GNUNET_NO;
dc->client = NULL;
}
dc->pending_head = NULL;