diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-05 00:16:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-05 00:16:00 +0000 |
commit | 0e5925b81384b8a8b12d950f23ff878d280a46a5 (patch) | |
tree | 83220ee9a055d81ac7c4fe08fcc4f1cae1ef33e5 | |
parent | f6e67ed3bb4cec5645b7cb81c44c34a115294051 (diff) | |
download | gnunet-0e5925b81384b8a8b12d950f23ff878d280a46a5.tar.gz gnunet-0e5925b81384b8a8b12d950f23ff878d280a46a5.zip |
-misc bugfixes
-rw-r--r-- | src/fs/fs_api.h | 5 | ||||
-rw-r--r-- | src/fs/fs_download.c | 18 | ||||
-rw-r--r-- | src/fs/fs_search.c | 4 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index 154e63893..7b44adef8 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h | |||
@@ -1616,6 +1616,11 @@ struct DownloadRequest | |||
1616 | unsigned int depth; | 1616 | unsigned int depth; |
1617 | 1617 | ||
1618 | /** | 1618 | /** |
1619 | * Offset of the CHK for this block in the parent block. | ||
1620 | */ | ||
1621 | unsigned int chk_idx; | ||
1622 | |||
1623 | /** | ||
1619 | * State in the FSM. | 1624 | * State in the FSM. |
1620 | */ | 1625 | */ |
1621 | enum BlockRequestState state; | 1626 | enum BlockRequestState state; |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 2efdcb019..d21386390 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -1103,13 +1103,13 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key, | |||
1103 | dr->depth, (unsigned long long) dr->offset); | 1103 | dr->depth, (unsigned long long) dr->offset); |
1104 | GNUNET_assert (0 == (prc->size % sizeof (struct ContentHashKey))); | 1104 | GNUNET_assert (0 == (prc->size % sizeof (struct ContentHashKey))); |
1105 | chkarr = (struct ContentHashKey *) pt; | 1105 | chkarr = (struct ContentHashKey *) pt; |
1106 | for (i = (prc->size / sizeof (struct ContentHashKey)) - 1; i >= 0; i--) | 1106 | for (i = dr->num_children - 1; i >= 0; i--) |
1107 | { | 1107 | { |
1108 | drc = dr->children[i]; | 1108 | drc = dr->children[i]; |
1109 | switch (drc->state) | 1109 | switch (drc->state) |
1110 | { | 1110 | { |
1111 | case BRS_INIT: | 1111 | case BRS_INIT: |
1112 | drc->chk = chkarr[i]; | 1112 | drc->chk = chkarr[dr->chk_idx]; |
1113 | drc->state = BRS_CHK_SET; | 1113 | drc->state = BRS_CHK_SET; |
1114 | schedule_block_download (dc, drc); | 1114 | schedule_block_download (dc, drc); |
1115 | break; | 1115 | break; |
@@ -1474,6 +1474,7 @@ deactivate_fs_download (void *cls) | |||
1474 | * (recursively) Create a download request structure. | 1474 | * (recursively) Create a download request structure. |
1475 | * | 1475 | * |
1476 | * @param parent parent of the current entry | 1476 | * @param parent parent of the current entry |
1477 | * @param chk_idx index of the chk for this block in the parent block | ||
1477 | * @param depth depth of the current entry, 0 are the DBLOCKs, | 1478 | * @param depth depth of the current entry, 0 are the DBLOCKs, |
1478 | * top level block is 'dc->treedepth - 1' | 1479 | * top level block is 'dc->treedepth - 1' |
1479 | * @param dr_offset offset in the original file this block maps to | 1480 | * @param dr_offset offset in the original file this block maps to |
@@ -1489,7 +1490,9 @@ deactivate_fs_download (void *cls) | |||
1489 | * the specified depth | 1490 | * the specified depth |
1490 | */ | 1491 | */ |
1491 | static struct DownloadRequest * | 1492 | static struct DownloadRequest * |
1492 | create_download_request (struct DownloadRequest *parent, unsigned int depth, | 1493 | create_download_request (struct DownloadRequest *parent, |
1494 | unsigned int chk_idx, | ||
1495 | unsigned int depth, | ||
1493 | uint64_t dr_offset, uint64_t file_start_offset, | 1496 | uint64_t dr_offset, uint64_t file_start_offset, |
1494 | uint64_t desired_length) | 1497 | uint64_t desired_length) |
1495 | { | 1498 | { |
@@ -1502,6 +1505,7 @@ create_download_request (struct DownloadRequest *parent, unsigned int depth, | |||
1502 | dr->parent = parent; | 1505 | dr->parent = parent; |
1503 | dr->depth = depth; | 1506 | dr->depth = depth; |
1504 | dr->offset = dr_offset; | 1507 | dr->offset = dr_offset; |
1508 | dr->chk_idx = chk_idx; | ||
1505 | if (depth > 0) | 1509 | if (depth > 0) |
1506 | { | 1510 | { |
1507 | child_block_size = GNUNET_FS_tree_compute_tree_size (depth - 1); | 1511 | child_block_size = GNUNET_FS_tree_compute_tree_size (depth - 1); |
@@ -1515,7 +1519,7 @@ create_download_request (struct DownloadRequest *parent, unsigned int depth, | |||
1515 | head_skip = dr_offset / child_block_size; | 1519 | head_skip = dr_offset / child_block_size; |
1516 | 1520 | ||
1517 | /* calculate index of last block at this level that is interesting (rounded up) */ | 1521 | /* calculate index of last block at this level that is interesting (rounded up) */ |
1518 | dr->num_children = file_start_offset + desired_length / child_block_size; | 1522 | dr->num_children = (file_start_offset + desired_length) / child_block_size; |
1519 | if (dr->num_children * child_block_size < | 1523 | if (dr->num_children * child_block_size < |
1520 | file_start_offset + desired_length) | 1524 | file_start_offset + desired_length) |
1521 | dr->num_children++; /* round up */ | 1525 | dr->num_children++; /* round up */ |
@@ -1532,8 +1536,8 @@ create_download_request (struct DownloadRequest *parent, unsigned int depth, | |||
1532 | GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *)); | 1536 | GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *)); |
1533 | for (i = 0; i < dr->num_children; i++) | 1537 | for (i = 0; i < dr->num_children; i++) |
1534 | dr->children[i] = | 1538 | dr->children[i] = |
1535 | create_download_request (dr, depth - 1, | 1539 | create_download_request (dr, i + head_skip, depth - 1, |
1536 | dr_offset + i * child_block_size, | 1540 | dr_offset + (i + head_skip) * child_block_size, |
1537 | file_start_offset, desired_length); | 1541 | file_start_offset, desired_length); |
1538 | } | 1542 | } |
1539 | return dr; | 1543 | return dr; |
@@ -1787,7 +1791,7 @@ GNUNET_FS_download_start_task_ (void *cls, | |||
1787 | if (dc->top_request == NULL) | 1791 | if (dc->top_request == NULL) |
1788 | { | 1792 | { |
1789 | dc->top_request = | 1793 | dc->top_request = |
1790 | create_download_request (NULL, dc->treedepth - 1, 0, dc->offset, | 1794 | create_download_request (NULL, 0, dc->treedepth - 1, 0, dc->offset, |
1791 | dc->length); | 1795 | dc->length); |
1792 | dc->top_request->state = BRS_CHK_SET; | 1796 | dc->top_request->state = BRS_CHK_SET; |
1793 | dc->top_request->chk = | 1797 | dc->top_request->chk = |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 994b97ce1..b2ccc0e16 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -1514,8 +1514,6 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | |||
1514 | GNUNET_FS_end_top (sc->h, sc->top); | 1514 | GNUNET_FS_end_top (sc->h, sc->top); |
1515 | if (sc->psearch_result != NULL) | 1515 | if (sc->psearch_result != NULL) |
1516 | sc->psearch_result->update_search = NULL; | 1516 | sc->psearch_result->update_search = NULL; |
1517 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | ||
1518 | &search_result_free, sc); | ||
1519 | if (sc->serialization != NULL) | 1517 | if (sc->serialization != NULL) |
1520 | { | 1518 | { |
1521 | GNUNET_FS_remove_sync_file_ (sc->h, | 1519 | GNUNET_FS_remove_sync_file_ (sc->h, |
@@ -1537,6 +1535,8 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | |||
1537 | GNUNET_SCHEDULER_cancel (sc->task); | 1535 | GNUNET_SCHEDULER_cancel (sc->task); |
1538 | if (NULL != sc->client) | 1536 | if (NULL != sc->client) |
1539 | GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); | 1537 | GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); |
1538 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | ||
1539 | &search_result_free, sc); | ||
1540 | GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); | 1540 | GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); |
1541 | if (sc->requests != NULL) | 1541 | if (sc->requests != NULL) |
1542 | { | 1542 | { |