diff options
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs.c | 91 | ||||
-rw-r--r-- | src/fs/fs.h | 22 | ||||
-rw-r--r-- | src/fs/fs_download.c | 28 | ||||
-rw-r--r-- | src/fs/fs_publish.c | 72 | ||||
-rw-r--r-- | src/fs/fs_search.c | 28 | ||||
-rw-r--r-- | src/fs/fs_unindex.c | 47 | ||||
-rw-r--r-- | src/fs/test_fs_download.c | 3 |
7 files changed, 185 insertions, 106 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c index 371568ddf..ba899d6d4 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c | |||
@@ -422,10 +422,11 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h, | |||
422 | &basename)) | 422 | &basename)) |
423 | return NULL; | 423 | return NULL; |
424 | GNUNET_asprintf (&ret, | 424 | GNUNET_asprintf (&ret, |
425 | "%s%s%s-%s%s%s", | 425 | "%s%s%s%s%s%s", |
426 | basename, | 426 | basename, |
427 | DIR_SEPARATOR_STR, | 427 | DIR_SEPARATOR_STR, |
428 | h->client_name, | 428 | h->client_name, |
429 | DIR_SEPARATOR_STR, | ||
429 | ext, | 430 | ext, |
430 | DIR_SEPARATOR_STR, | 431 | DIR_SEPARATOR_STR, |
431 | ent); | 432 | ent); |
@@ -514,6 +515,40 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, | |||
514 | 515 | ||
515 | 516 | ||
516 | /** | 517 | /** |
518 | * Remove serialization/deserialization directory from disk. | ||
519 | * | ||
520 | * @param h master context | ||
521 | * @param ext component of the path | ||
522 | * @param uni unique name of parent | ||
523 | */ | ||
524 | void | ||
525 | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, | ||
526 | const char *ext, | ||
527 | const char *uni) | ||
528 | { | ||
529 | char *dn; | ||
530 | char pbuf[32]; | ||
531 | |||
532 | if (uni == NULL) | ||
533 | return; | ||
534 | GNUNET_snprintf (pbuf, | ||
535 | sizeof (pbuf), | ||
536 | "%s%s%s", | ||
537 | ext, | ||
538 | DIR_SEPARATOR_STR, | ||
539 | uni); | ||
540 | dn = get_serialization_file_name (h, ext, ""); | ||
541 | if (dn == NULL) | ||
542 | return; | ||
543 | if (GNUNET_OK != GNUNET_DISK_directory_remove (dn)) | ||
544 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
545 | "rmdir", | ||
546 | dn); | ||
547 | GNUNET_free (dn); | ||
548 | } | ||
549 | |||
550 | |||
551 | /** | ||
517 | * Serialize a 'start_time'. Since we use start-times to | 552 | * Serialize a 'start_time'. Since we use start-times to |
518 | * calculate the duration of some operation, we actually | 553 | * calculate the duration of some operation, we actually |
519 | * do not serialize the absolute time but the (relative) | 554 | * do not serialize the absolute time but the (relative) |
@@ -1397,7 +1432,6 @@ void | |||
1397 | GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | 1432 | GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) |
1398 | { | 1433 | { |
1399 | struct GNUNET_BIO_WriteHandle *wh; | 1434 | struct GNUNET_BIO_WriteHandle *wh; |
1400 | struct DownloadRequest *dr; | ||
1401 | char pbuf[32]; | 1435 | char pbuf[32]; |
1402 | const char *category; | 1436 | const char *category; |
1403 | char *uris; | 1437 | char *uris; |
@@ -1437,17 +1471,9 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1437 | uris = GNUNET_FS_uri_to_string (dc->uri); | 1471 | uris = GNUNET_FS_uri_to_string (dc->uri); |
1438 | num_pending = 0; | 1472 | num_pending = 0; |
1439 | if (dc->emsg != NULL) | 1473 | if (dc->emsg != NULL) |
1440 | { | 1474 | (void) GNUNET_CONTAINER_multihashmap_iterate (dc->active, |
1441 | dr = dc->pending; | 1475 | &count_download_requests, |
1442 | while (dr != NULL) | 1476 | &num_pending); |
1443 | { | ||
1444 | num_pending++; | ||
1445 | dr = dr->next; | ||
1446 | } | ||
1447 | (void) GNUNET_CONTAINER_multihashmap_iterate (dc->active, | ||
1448 | &count_download_requests, | ||
1449 | &num_pending); | ||
1450 | } | ||
1451 | GNUNET_assert ( (dc->length == dc->completed) || | 1477 | GNUNET_assert ( (dc->length == dc->completed) || |
1452 | (dc->emsg != NULL) || | 1478 | (dc->emsg != NULL) || |
1453 | (num_pending > 0) ); | 1479 | (num_pending > 0) ); |
@@ -1480,28 +1506,11 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1480 | (GNUNET_OK != | 1506 | (GNUNET_OK != |
1481 | GNUNET_BIO_write_int32 (wh, num_pending)) ) | 1507 | GNUNET_BIO_write_int32 (wh, num_pending)) ) |
1482 | goto cleanup; | 1508 | goto cleanup; |
1483 | dr = dc->pending; | ||
1484 | while (dr != NULL) | ||
1485 | { | ||
1486 | if (GNUNET_YES != | ||
1487 | write_download_request (wh, NULL, dr)) | ||
1488 | goto cleanup; | ||
1489 | dr = dr->next; | ||
1490 | } | ||
1491 | if (GNUNET_SYSERR == | 1509 | if (GNUNET_SYSERR == |
1492 | GNUNET_CONTAINER_multihashmap_iterate (dc->active, | 1510 | GNUNET_CONTAINER_multihashmap_iterate (dc->active, |
1493 | &write_download_request, | 1511 | &write_download_request, |
1494 | wh)) | 1512 | wh)) |
1495 | goto cleanup; | 1513 | goto cleanup; |
1496 | while (0 < num_pending--) | ||
1497 | { | ||
1498 | dr = GNUNET_malloc (sizeof (struct DownloadRequest)); | ||
1499 | |||
1500 | dr->is_pending = GNUNET_YES; | ||
1501 | dr->next = dc->pending; | ||
1502 | dc->pending = dr; | ||
1503 | dr = NULL; | ||
1504 | } | ||
1505 | GNUNET_free_non_null (uris); | 1514 | GNUNET_free_non_null (uris); |
1506 | if (GNUNET_OK == | 1515 | if (GNUNET_OK == |
1507 | GNUNET_BIO_write_close (wh)) | 1516 | GNUNET_BIO_write_close (wh)) |
@@ -1524,18 +1533,14 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1524 | * publishing structs should already call "sync" internally, | 1533 | * publishing structs should already call "sync" internally, |
1525 | * so this function is likely not useful for clients. | 1534 | * so this function is likely not useful for clients. |
1526 | * | 1535 | * |
1527 | * @param key key for the search result | ||
1528 | * @param sr the struct to sync | 1536 | * @param sr the struct to sync |
1529 | */ | 1537 | */ |
1530 | void | 1538 | void |
1531 | GNUNET_FS_search_result_sync_ (const GNUNET_HashCode *key, | 1539 | GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) |
1532 | struct GNUNET_FS_SearchResult *sr) | ||
1533 | { | 1540 | { |
1534 | struct GNUNET_BIO_WriteHandle *wh; | 1541 | struct GNUNET_BIO_WriteHandle *wh; |
1535 | char *uris; | 1542 | char *uris; |
1536 | 1543 | ||
1537 | GNUNET_assert ( (GNUNET_YES == GNUNET_FS_uri_test_chk (sr->uri)) || | ||
1538 | (GNUNET_YES == GNUNET_FS_uri_test_loc (sr->uri)) ); | ||
1539 | uris = NULL; | 1544 | uris = NULL; |
1540 | if (NULL == sr->serialization) | 1545 | if (NULL == sr->serialization) |
1541 | sr->serialization = make_serialization_file_name (sr->sc->h, | 1546 | sr->serialization = make_serialization_file_name (sr->sc->h, |
@@ -1551,7 +1556,7 @@ GNUNET_FS_search_result_sync_ (const GNUNET_HashCode *key, | |||
1551 | (GNUNET_OK != | 1556 | (GNUNET_OK != |
1552 | GNUNET_BIO_write_meta_data (wh, sr->meta)) || | 1557 | GNUNET_BIO_write_meta_data (wh, sr->meta)) || |
1553 | (GNUNET_OK != | 1558 | (GNUNET_OK != |
1554 | GNUNET_BIO_write (wh, key, sizeof (GNUNET_HashCode))) || | 1559 | GNUNET_BIO_write (wh, &sr->key, sizeof (GNUNET_HashCode))) || |
1555 | (GNUNET_OK != | 1560 | (GNUNET_OK != |
1556 | GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) || | 1561 | GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) || |
1557 | (GNUNET_OK != | 1562 | (GNUNET_OK != |
@@ -1844,7 +1849,6 @@ deserialize_search_result (void *cls, | |||
1844 | struct GNUNET_BIO_ReadHandle *rh; | 1849 | struct GNUNET_BIO_ReadHandle *rh; |
1845 | struct GNUNET_BIO_ReadHandle *drh; | 1850 | struct GNUNET_BIO_ReadHandle *drh; |
1846 | struct GNUNET_FS_SearchResult *sr; | 1851 | struct GNUNET_FS_SearchResult *sr; |
1847 | GNUNET_HashCode key; | ||
1848 | 1852 | ||
1849 | ser = get_serialization_short_name (filename); | 1853 | ser = get_serialization_short_name (filename); |
1850 | rh = GNUNET_BIO_read_open (filename); | 1854 | rh = GNUNET_BIO_read_open (filename); |
@@ -1871,14 +1875,12 @@ deserialize_search_result (void *cls, | |||
1871 | if ( (GNUNET_OK != | 1875 | if ( (GNUNET_OK != |
1872 | GNUNET_BIO_read_string (rh, "result-uri", &uris, 10*1024)) || | 1876 | GNUNET_BIO_read_string (rh, "result-uri", &uris, 10*1024)) || |
1873 | (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) || | 1877 | (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) || |
1874 | ( (GNUNET_YES != GNUNET_FS_uri_test_chk (sr->uri)) && | ||
1875 | (GNUNET_YES != GNUNET_FS_uri_test_loc (sr->uri)) ) || | ||
1876 | (GNUNET_OK != | 1878 | (GNUNET_OK != |
1877 | GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || | 1879 | GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || |
1878 | (GNUNET_OK != | 1880 | (GNUNET_OK != |
1879 | GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || | 1881 | GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || |
1880 | (GNUNET_OK != | 1882 | (GNUNET_OK != |
1881 | GNUNET_BIO_read (rh, "result-key", &key, sizeof (key))) || | 1883 | GNUNET_BIO_read (rh, "result-key", &sr->key, sizeof (GNUNET_HashCode))) || |
1882 | (GNUNET_OK != | 1884 | (GNUNET_OK != |
1883 | GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) || | 1885 | GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) || |
1884 | (GNUNET_OK != | 1886 | (GNUNET_OK != |
@@ -1911,7 +1913,7 @@ deserialize_search_result (void *cls, | |||
1911 | GNUNET_free (download); | 1913 | GNUNET_free (download); |
1912 | } | 1914 | } |
1913 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, | 1915 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, |
1914 | &key, | 1916 | &sr->key, |
1915 | sr, | 1917 | sr, |
1916 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1918 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1917 | return GNUNET_OK; | 1919 | return GNUNET_OK; |
@@ -2476,9 +2478,12 @@ deserialize_download_file (void *cls, | |||
2476 | rh = GNUNET_BIO_read_open (filename); | 2478 | rh = GNUNET_BIO_read_open (filename); |
2477 | if (rh == NULL) | 2479 | if (rh == NULL) |
2478 | { | 2480 | { |
2479 | if (ser != NULL) | 2481 | if (filename != NULL) |
2480 | { | 2482 | { |
2481 | GNUNET_FS_remove_sync_file_ (h, "download", ser); | 2483 | if (0 != UNLINK (filename)) |
2484 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
2485 | "unlink", | ||
2486 | filename); | ||
2482 | GNUNET_free (ser); | 2487 | GNUNET_free (ser); |
2483 | } | 2488 | } |
2484 | return GNUNET_OK; | 2489 | return GNUNET_OK; |
diff --git a/src/fs/fs.h b/src/fs/fs.h index 1d3498a7c..52fbee4c1 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -621,6 +621,11 @@ struct GNUNET_FS_SearchResult | |||
621 | char *serialization; | 621 | char *serialization; |
622 | 622 | ||
623 | /** | 623 | /** |
624 | * Key for the search result | ||
625 | */ | ||
626 | GNUNET_HashCode key; | ||
627 | |||
628 | /** | ||
624 | * ID of the task that will clean up the probe_ctx should it not | 629 | * ID of the task that will clean up the probe_ctx should it not |
625 | * complete on time (and that will need to be cancelled if we clean | 630 | * complete on time (and that will need to be cancelled if we clean |
626 | * up the search result before then). | 631 | * up the search result before then). |
@@ -895,6 +900,19 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, | |||
895 | 900 | ||
896 | 901 | ||
897 | /** | 902 | /** |
903 | * Remove serialization/deserialization directory from disk. | ||
904 | * | ||
905 | * @param h master context | ||
906 | * @param ext component of the path | ||
907 | * @param uni unique name of parent | ||
908 | */ | ||
909 | void | ||
910 | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, | ||
911 | const char *ext, | ||
912 | const char *uni); | ||
913 | |||
914 | |||
915 | /** | ||
898 | * Synchronize this file-information struct with its mirror | 916 | * Synchronize this file-information struct with its mirror |
899 | * on disk. Note that all internal FS-operations that change | 917 | * on disk. Note that all internal FS-operations that change |
900 | * file information data should already call "sync" internally, | 918 | * file information data should already call "sync" internally, |
@@ -944,12 +962,10 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); | |||
944 | * publishing structs should already call "sync" internally, | 962 | * publishing structs should already call "sync" internally, |
945 | * so this function is likely not useful for clients. | 963 | * so this function is likely not useful for clients. |
946 | * | 964 | * |
947 | * @param key key for the search result | ||
948 | * @param sr the struct to sync | 965 | * @param sr the struct to sync |
949 | */ | 966 | */ |
950 | void | 967 | void |
951 | GNUNET_FS_search_result_sync_ (const GNUNET_HashCode *key, | 968 | GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr); |
952 | struct GNUNET_FS_SearchResult *sr); | ||
953 | 969 | ||
954 | /** | 970 | /** |
955 | * Synchronize this download struct with its mirror | 971 | * Synchronize this download struct with its mirror |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 2fd8e0412..8d5a936f0 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -23,7 +23,6 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | * | 24 | * |
25 | * TODO: | 25 | * TODO: |
26 | * - persistence (can wait) | ||
27 | * - location URI suppport (can wait, easy) | 26 | * - location URI suppport (can wait, easy) |
28 | * - different priority for scheduling probe downloads? | 27 | * - different priority for scheduling probe downloads? |
29 | * - check if iblocks can be computed from existing blocks (can wait, hard) | 28 | * - check if iblocks can be computed from existing blocks (can wait, hard) |
@@ -640,6 +639,7 @@ check_completed (struct GNUNET_FS_DownloadContext *dc) | |||
640 | pos = pos->next; | 639 | pos = pos->next; |
641 | } | 640 | } |
642 | dc->has_finished = GNUNET_YES; | 641 | dc->has_finished = GNUNET_YES; |
642 | GNUNET_FS_download_sync_ (dc); | ||
643 | /* signal completion */ | 643 | /* signal completion */ |
644 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED; | 644 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED; |
645 | GNUNET_FS_download_make_status_ (&pi, dc); | 645 | GNUNET_FS_download_make_status_ (&pi, dc); |
@@ -1032,9 +1032,9 @@ process_result_with_request (void *cls, | |||
1032 | } | 1032 | } |
1033 | GNUNET_assert (sm->depth == dc->treedepth); | 1033 | GNUNET_assert (sm->depth == dc->treedepth); |
1034 | } | 1034 | } |
1035 | // FIXME: make persistent | ||
1036 | if (sm->depth == dc->treedepth) | 1035 | if (sm->depth == dc->treedepth) |
1037 | { | 1036 | { |
1037 | GNUNET_FS_download_sync_ (dc); | ||
1038 | GNUNET_free (sm); | 1038 | GNUNET_free (sm); |
1039 | return GNUNET_YES; | 1039 | return GNUNET_YES; |
1040 | } | 1040 | } |
@@ -1060,6 +1060,7 @@ process_result_with_request (void *cls, | |||
1060 | sm->depth + 1); | 1060 | sm->depth + 1); |
1061 | } | 1061 | } |
1062 | GNUNET_free (sm); | 1062 | GNUNET_free (sm); |
1063 | GNUNET_FS_download_sync_ (dc); | ||
1063 | return GNUNET_YES; | 1064 | return GNUNET_YES; |
1064 | 1065 | ||
1065 | signal_error: | 1066 | signal_error: |
@@ -1075,8 +1076,10 @@ process_result_with_request (void *cls, | |||
1075 | dc->th = NULL; | 1076 | dc->th = NULL; |
1076 | } | 1077 | } |
1077 | GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO); | 1078 | GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO); |
1079 | /* FIXME: clean up dc->active / pending! */ | ||
1078 | dc->client = NULL; | 1080 | dc->client = NULL; |
1079 | GNUNET_free (sm); | 1081 | GNUNET_free (sm); |
1082 | GNUNET_FS_download_sync_ (dc); | ||
1080 | return GNUNET_NO; | 1083 | return GNUNET_NO; |
1081 | } | 1084 | } |
1082 | 1085 | ||
@@ -1553,7 +1556,6 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, | |||
1553 | "Download tree has depth %u\n", | 1556 | "Download tree has depth %u\n", |
1554 | dc->treedepth); | 1557 | dc->treedepth); |
1555 | #endif | 1558 | #endif |
1556 | // FIXME: make persistent | ||
1557 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; | 1559 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; |
1558 | pi.value.download.specifics.start.meta = meta; | 1560 | pi.value.download.specifics.start.meta = meta; |
1559 | GNUNET_FS_download_make_status_ (&pi, dc); | 1561 | GNUNET_FS_download_make_status_ (&pi, dc); |
@@ -1561,6 +1563,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, | |||
1561 | &dc->uri->data.chk.chk, | 1563 | &dc->uri->data.chk.chk, |
1562 | 0, | 1564 | 0, |
1563 | 1 /* 0 == CHK, 1 == top */); | 1565 | 1 /* 0 == CHK, 1 == top */); |
1566 | GNUNET_FS_download_sync_ (dc); | ||
1564 | GNUNET_FS_download_start_downloading_ (dc); | 1567 | GNUNET_FS_download_start_downloading_ (dc); |
1565 | if (parent == NULL) | 1568 | if (parent == NULL) |
1566 | dc->top = GNUNET_FS_make_top (dc->h, | 1569 | dc->top = GNUNET_FS_make_top (dc->h, |
@@ -1682,7 +1685,6 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, | |||
1682 | "Download tree has depth %u\n", | 1685 | "Download tree has depth %u\n", |
1683 | dc->treedepth); | 1686 | dc->treedepth); |
1684 | #endif | 1687 | #endif |
1685 | // FIXME: make persistent | ||
1686 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; | 1688 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; |
1687 | pi.value.download.specifics.start.meta = dc->meta; | 1689 | pi.value.download.specifics.start.meta = dc->meta; |
1688 | GNUNET_FS_download_make_status_ (&pi, dc); | 1690 | GNUNET_FS_download_make_status_ (&pi, dc); |
@@ -1690,6 +1692,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, | |||
1690 | &dc->uri->data.chk.chk, | 1692 | &dc->uri->data.chk.chk, |
1691 | 0, | 1693 | 0, |
1692 | 1 /* 0 == CHK, 1 == top */); | 1694 | 1 /* 0 == CHK, 1 == top */); |
1695 | GNUNET_FS_download_sync_ (dc); | ||
1693 | GNUNET_FS_download_start_downloading_ (dc); | 1696 | GNUNET_FS_download_start_downloading_ (dc); |
1694 | return dc; | 1697 | return dc; |
1695 | } | 1698 | } |
@@ -1722,6 +1725,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, | |||
1722 | int do_delete) | 1725 | int do_delete) |
1723 | { | 1726 | { |
1724 | struct GNUNET_FS_ProgressInfo pi; | 1727 | struct GNUNET_FS_ProgressInfo pi; |
1728 | int have_children; | ||
1725 | 1729 | ||
1726 | if (dc->top != NULL) | 1730 | if (dc->top != NULL) |
1727 | GNUNET_FS_end_top (dc->h, dc->top); | 1731 | GNUNET_FS_end_top (dc->h, dc->top); |
@@ -1735,15 +1739,24 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, | |||
1735 | GNUNET_FS_dequeue_ (dc->job_queue); | 1739 | GNUNET_FS_dequeue_ (dc->job_queue); |
1736 | dc->job_queue = NULL; | 1740 | dc->job_queue = NULL; |
1737 | } | 1741 | } |
1742 | have_children = (NULL != dc->child_head) ? GNUNET_YES : GNUNET_NO; | ||
1738 | while (NULL != dc->child_head) | 1743 | while (NULL != dc->child_head) |
1739 | GNUNET_FS_download_stop (dc->child_head, | 1744 | GNUNET_FS_download_stop (dc->child_head, |
1740 | do_delete); | 1745 | do_delete); |
1741 | // FIXME: make unpersistent | ||
1742 | if (dc->parent != NULL) | 1746 | if (dc->parent != NULL) |
1743 | GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, | 1747 | GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, |
1744 | dc->parent->child_tail, | 1748 | dc->parent->child_tail, |
1745 | dc); | 1749 | dc); |
1746 | 1750 | if (dc->serialization != NULL) | |
1751 | GNUNET_FS_remove_sync_file_ (dc->h, | ||
1752 | (dc->parent != NULL) | ||
1753 | ? "subdownloads" | ||
1754 | : "download", | ||
1755 | dc->serialization); | ||
1756 | if (GNUNET_YES == have_children) | ||
1757 | GNUNET_FS_remove_sync_dir_ (dc->h, | ||
1758 | "subdownloads", | ||
1759 | dc->serialization); | ||
1747 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; | 1760 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; |
1748 | GNUNET_FS_download_make_status_ (&pi, dc); | 1761 | GNUNET_FS_download_make_status_ (&pi, dc); |
1749 | if (GNUNET_SCHEDULER_NO_TASK != dc->task) | 1762 | if (GNUNET_SCHEDULER_NO_TASK != dc->task) |
@@ -1775,7 +1788,6 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, | |||
1775 | dc->temp_filename); | 1788 | dc->temp_filename); |
1776 | GNUNET_free (dc->temp_filename); | 1789 | GNUNET_free (dc->temp_filename); |
1777 | } | 1790 | } |
1778 | /* FIXME: clean up serialization file itself! */ | ||
1779 | GNUNET_free_non_null (dc->serialization); | 1791 | GNUNET_free_non_null (dc->serialization); |
1780 | GNUNET_free (dc); | 1792 | GNUNET_free (dc); |
1781 | } | 1793 | } |
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 0c4ebba7b..8d2dacb14 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -21,13 +21,12 @@ | |||
21 | /** | 21 | /** |
22 | * @file fs/fs_publish.c | 22 | * @file fs/fs_publish.c |
23 | * @brief publish a file or directory in GNUnet | 23 | * @brief publish a file or directory in GNUnet |
24 | * @see http://gnunet.org/encoding.php3 | 24 | * @see http://gnunet.org/encoding |
25 | * @author Krista Bennett | 25 | * @author Krista Bennett |
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | * | 27 | * |
28 | * TODO: | 28 | * TODO: |
29 | * - indexing cleanup: unindex on failure (can wait) | 29 | * - indexing cleanup: unindex on failure (can wait) |
30 | * - persistence support (can wait) | ||
31 | * - datastore reservation support (optimization) | 30 | * - datastore reservation support (optimization) |
32 | * - location URIs (publish with anonymity-level zero) | 31 | * - location URIs (publish with anonymity-level zero) |
33 | */ | 32 | */ |
@@ -191,7 +190,7 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, | |||
191 | pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; | 190 | pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; |
192 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; | 191 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; |
193 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, | 192 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, |
194 | GNUNET_ntohll (p->chk_uri->data.chk.file_length)); | 193 | GNUNET_ntohll (p->chk_uri->data.chk.file_length)); |
195 | } | 194 | } |
196 | 195 | ||
197 | 196 | ||
@@ -232,17 +231,19 @@ publish_sblocks_cont (void *cls, | |||
232 | const struct GNUNET_FS_Uri *uri, | 231 | const struct GNUNET_FS_Uri *uri, |
233 | const char *emsg) | 232 | const char *emsg) |
234 | { | 233 | { |
235 | struct GNUNET_FS_PublishContext *sc = cls; | 234 | struct GNUNET_FS_PublishContext *pc = cls; |
236 | if (NULL != emsg) | 235 | if (NULL != emsg) |
237 | { | 236 | { |
238 | signal_publish_error (sc->fi, | 237 | signal_publish_error (pc->fi, |
239 | sc, | 238 | pc, |
240 | emsg); | 239 | emsg); |
240 | GNUNET_FS_publish_sync_ (pc); | ||
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | // FIXME: release the datastore reserve here! | 243 | // FIXME: release the datastore reserve here! |
244 | signal_publish_completion (sc->fi, sc); | 244 | signal_publish_completion (pc->fi, pc); |
245 | sc->all_done = GNUNET_YES; | 245 | pc->all_done = GNUNET_YES; |
246 | GNUNET_FS_publish_sync_ (pc); | ||
246 | } | 247 | } |
247 | 248 | ||
248 | 249 | ||
@@ -287,31 +288,34 @@ publish_kblocks_cont (void *cls, | |||
287 | const struct GNUNET_FS_Uri *uri, | 288 | const struct GNUNET_FS_Uri *uri, |
288 | const char *emsg) | 289 | const char *emsg) |
289 | { | 290 | { |
290 | struct GNUNET_FS_PublishContext *sc = cls; | 291 | struct GNUNET_FS_PublishContext *pc = cls; |
291 | struct GNUNET_FS_FileInformation *p = sc->fi_pos; | 292 | struct GNUNET_FS_FileInformation *p = pc->fi_pos; |
292 | 293 | ||
293 | if (NULL != emsg) | 294 | if (NULL != emsg) |
294 | { | 295 | { |
295 | signal_publish_error (p, sc, emsg); | 296 | signal_publish_error (p, pc, emsg); |
296 | sc->upload_task | 297 | GNUNET_FS_file_information_sync_ (p); |
297 | = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, | 298 | GNUNET_FS_publish_sync_ (pc); |
299 | pc->upload_task | ||
300 | = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, | ||
298 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 301 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
299 | &GNUNET_FS_publish_main_, | 302 | &GNUNET_FS_publish_main_, |
300 | sc); | 303 | pc); |
301 | return; | 304 | return; |
302 | } | 305 | } |
303 | if (NULL != p->dir) | 306 | if (NULL != p->dir) |
304 | signal_publish_completion (p, sc); | 307 | signal_publish_completion (p, pc); |
305 | /* move on to next file */ | 308 | /* move on to next file */ |
306 | if (NULL != p->next) | 309 | if (NULL != p->next) |
307 | sc->fi_pos = p->next; | 310 | pc->fi_pos = p->next; |
308 | else | 311 | else |
309 | sc->fi_pos = p->dir; | 312 | pc->fi_pos = p->dir; |
310 | sc->upload_task | 313 | GNUNET_FS_publish_sync_ (pc); |
311 | = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, | 314 | pc->upload_task |
315 | = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, | ||
312 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 316 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
313 | &GNUNET_FS_publish_main_, | 317 | &GNUNET_FS_publish_main_, |
314 | sc); | 318 | pc); |
315 | } | 319 | } |
316 | 320 | ||
317 | 321 | ||
@@ -597,6 +601,7 @@ publish_content (struct GNUNET_FS_PublishContext *sc) | |||
597 | GNUNET_FS_directory_builder_finish (db, | 601 | GNUNET_FS_directory_builder_finish (db, |
598 | &p->data.dir.dir_size, | 602 | &p->data.dir.dir_size, |
599 | &p->data.dir.dir_data); | 603 | &p->data.dir.dir_data); |
604 | GNUNET_FS_file_information_sync_ (p); | ||
600 | } | 605 | } |
601 | size = (p->is_directory) | 606 | size = (p->is_directory) |
602 | ? p->data.dir.dir_size | 607 | ? p->data.dir.dir_size |
@@ -640,6 +645,7 @@ process_index_start_response (void *cls, | |||
640 | p->filename, | 645 | p->filename, |
641 | _("timeout on index-start request to `fs' service")); | 646 | _("timeout on index-start request to `fs' service")); |
642 | p->data.file.do_index = GNUNET_NO; | 647 | p->data.file.do_index = GNUNET_NO; |
648 | GNUNET_FS_file_information_sync_ (p); | ||
643 | publish_content (sc); | 649 | publish_content (sc); |
644 | return; | 650 | return; |
645 | } | 651 | } |
@@ -655,11 +661,13 @@ process_index_start_response (void *cls, | |||
655 | p->filename, | 661 | p->filename, |
656 | gettext (emsg)); | 662 | gettext (emsg)); |
657 | p->data.file.do_index = GNUNET_NO; | 663 | p->data.file.do_index = GNUNET_NO; |
664 | GNUNET_FS_file_information_sync_ (p); | ||
658 | publish_content (sc); | 665 | publish_content (sc); |
659 | return; | 666 | return; |
660 | } | 667 | } |
661 | p->data.file.index_start_confirmed = GNUNET_YES; | 668 | p->data.file.index_start_confirmed = GNUNET_YES; |
662 | /* success! continue with indexing */ | 669 | /* success! continue with indexing */ |
670 | GNUNET_FS_file_information_sync_ (p); | ||
663 | publish_content (sc); | 671 | publish_content (sc); |
664 | } | 672 | } |
665 | 673 | ||
@@ -693,6 +701,7 @@ hash_for_index_cb (void *cls, | |||
693 | p->filename, | 701 | p->filename, |
694 | _("failed to compute hash")); | 702 | _("failed to compute hash")); |
695 | p->data.file.do_index = GNUNET_NO; | 703 | p->data.file.do_index = GNUNET_NO; |
704 | GNUNET_FS_file_information_sync_ (p); | ||
696 | publish_content (sc); | 705 | publish_content (sc); |
697 | return; | 706 | return; |
698 | } | 707 | } |
@@ -711,6 +720,7 @@ hash_for_index_cb (void *cls, | |||
711 | _("filename too long")); | 720 | _("filename too long")); |
712 | GNUNET_free (fn); | 721 | GNUNET_free (fn); |
713 | p->data.file.do_index = GNUNET_NO; | 722 | p->data.file.do_index = GNUNET_NO; |
723 | GNUNET_FS_file_information_sync_ (p); | ||
714 | publish_content (sc); | 724 | publish_content (sc); |
715 | return; | 725 | return; |
716 | } | 726 | } |
@@ -734,8 +744,12 @@ hash_for_index_cb (void *cls, | |||
734 | GNUNET_free (fn); | 744 | GNUNET_free (fn); |
735 | return; | 745 | return; |
736 | } | 746 | } |
737 | p->data.file.file_id = *res; | 747 | if (p->data.file.have_hash != GNUNET_YES) |
738 | p->data.file.have_hash = GNUNET_YES; | 748 | { |
749 | p->data.file.file_id = *res; | ||
750 | p->data.file.have_hash = GNUNET_YES; | ||
751 | GNUNET_FS_file_information_sync_ (p); | ||
752 | } | ||
739 | ism = GNUNET_malloc (sizeof(struct IndexStartMessage) + | 753 | ism = GNUNET_malloc (sizeof(struct IndexStartMessage) + |
740 | slen); | 754 | slen); |
741 | ism->header.size = htons(sizeof(struct IndexStartMessage) + | 755 | ism->header.size = htons(sizeof(struct IndexStartMessage) + |
@@ -793,6 +807,7 @@ GNUNET_FS_publish_main_ (void *cls, | |||
793 | { | 807 | { |
794 | /* upload of entire hierarchy complete, | 808 | /* upload of entire hierarchy complete, |
795 | publish namespace entries */ | 809 | publish namespace entries */ |
810 | GNUNET_FS_publish_sync_ (sc); | ||
796 | publish_sblock (sc); | 811 | publish_sblock (sc); |
797 | return; | 812 | return; |
798 | } | 813 | } |
@@ -804,6 +819,7 @@ GNUNET_FS_publish_main_ (void *cls, | |||
804 | { | 819 | { |
805 | p = p->data.dir.entries; | 820 | p = p->data.dir.entries; |
806 | sc->fi_pos = p; | 821 | sc->fi_pos = p; |
822 | GNUNET_FS_publish_sync_ (sc); | ||
807 | } | 823 | } |
808 | /* abort on error */ | 824 | /* abort on error */ |
809 | if (NULL != p->emsg) | 825 | if (NULL != p->emsg) |
@@ -835,11 +851,13 @@ GNUNET_FS_publish_main_ (void *cls, | |||
835 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, 0); | 851 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, 0); |
836 | } | 852 | } |
837 | sc->all_done = GNUNET_YES; | 853 | sc->all_done = GNUNET_YES; |
854 | GNUNET_FS_publish_sync_ (sc); | ||
838 | return; | 855 | return; |
839 | } | 856 | } |
840 | /* handle completion */ | 857 | /* handle completion */ |
841 | if (NULL != p->chk_uri) | 858 | if (NULL != p->chk_uri) |
842 | { | 859 | { |
860 | GNUNET_FS_publish_sync_ (sc); | ||
843 | /* upload of "p" complete, publish KBlocks! */ | 861 | /* upload of "p" complete, publish KBlocks! */ |
844 | if (p->keywords != NULL) | 862 | if (p->keywords != NULL) |
845 | { | 863 | { |
@@ -872,12 +890,15 @@ GNUNET_FS_publish_main_ (void *cls, | |||
872 | _("Can not index file `%s': %s. Will try to insert instead.\n"), | 890 | _("Can not index file `%s': %s. Will try to insert instead.\n"), |
873 | "<no-name>", | 891 | "<no-name>", |
874 | _("needs to be an actual file")); | 892 | _("needs to be an actual file")); |
893 | GNUNET_FS_file_information_sync_ (p); | ||
875 | publish_content (sc); | 894 | publish_content (sc); |
876 | return; | 895 | return; |
877 | } | 896 | } |
878 | if (p->data.file.have_hash) | 897 | if (p->data.file.have_hash) |
879 | hash_for_index_cb (sc, | 898 | { |
880 | &p->data.file.file_id); | 899 | hash_for_index_cb (sc, |
900 | &p->data.file.file_id); | ||
901 | } | ||
881 | else | 902 | else |
882 | { | 903 | { |
883 | p->start_time = GNUNET_TIME_absolute_get (); | 904 | p->start_time = GNUNET_TIME_absolute_get (); |
@@ -925,6 +946,7 @@ fip_signal_start(void *cls, | |||
925 | 946 | ||
926 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; | 947 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; |
927 | *client_info = GNUNET_FS_publish_make_status_ (&pi, sc, fi, 0); | 948 | *client_info = GNUNET_FS_publish_make_status_ (&pi, sc, fi, 0); |
949 | GNUNET_FS_file_information_sync_ (fi); | ||
928 | return GNUNET_OK; | 950 | return GNUNET_OK; |
929 | } | 951 | } |
930 | 952 | ||
@@ -962,7 +984,7 @@ fip_signal_suspend(void *cls, | |||
962 | GNUNET_free_non_null (fi->serialization); | 984 | GNUNET_free_non_null (fi->serialization); |
963 | fi->serialization = NULL; | 985 | fi->serialization = NULL; |
964 | off = (fi->chk_uri == NULL) ? 0 : length; | 986 | off = (fi->chk_uri == NULL) ? 0 : length; |
965 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; | 987 | pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; |
966 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off)); | 988 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off)); |
967 | *client_info = NULL; | 989 | *client_info = NULL; |
968 | return GNUNET_OK; | 990 | return GNUNET_OK; |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 36aa26193..8db9f115d 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -24,7 +24,6 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * TODO: | 26 | * TODO: |
27 | * - insert code for serialization where needed | ||
28 | * - remove *directory* with search results upon completion | 27 | * - remove *directory* with search results upon completion |
29 | * - centralize code that sprintf's the 'pbuf[32]' strings | 28 | * - centralize code that sprintf's the 'pbuf[32]' strings |
30 | * - add support for pushing "already seen" information | 29 | * - add support for pushing "already seen" information |
@@ -52,7 +51,8 @@ | |||
52 | void * | 51 | void * |
53 | GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | 52 | GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, |
54 | struct GNUNET_FS_SearchContext *sc) | 53 | struct GNUNET_FS_SearchContext *sc) |
55 | { | 54 | { |
55 | void *ret; | ||
56 | pi->value.search.sc = sc; | 56 | pi->value.search.sc = sc; |
57 | pi->value.search.cctx | 57 | pi->value.search.cctx |
58 | = sc->client_info; | 58 | = sc->client_info; |
@@ -62,8 +62,9 @@ GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
62 | = sc->uri; | 62 | = sc->uri; |
63 | pi->value.search.duration = GNUNET_TIME_absolute_get_duration (sc->start_time); | 63 | pi->value.search.duration = GNUNET_TIME_absolute_get_duration (sc->start_time); |
64 | pi->value.search.anonymity = sc->anonymity; | 64 | pi->value.search.anonymity = sc->anonymity; |
65 | return sc->h->upcb (sc->h->upcb_cls, | 65 | ret = sc->h->upcb (sc->h->upcb_cls, |
66 | pi); | 66 | pi); |
67 | return ret; | ||
67 | } | 68 | } |
68 | 69 | ||
69 | 70 | ||
@@ -217,6 +218,7 @@ probe_failure_handler (void *cls, | |||
217 | { | 218 | { |
218 | struct GNUNET_FS_SearchResult *sr = cls; | 219 | struct GNUNET_FS_SearchResult *sr = cls; |
219 | sr->availability_trials++; | 220 | sr->availability_trials++; |
221 | GNUNET_FS_search_result_sync_ (sr); | ||
220 | signal_probe_result (sr); | 222 | signal_probe_result (sr); |
221 | } | 223 | } |
222 | 224 | ||
@@ -234,6 +236,7 @@ probe_success_handler (void *cls, | |||
234 | struct GNUNET_FS_SearchResult *sr = cls; | 236 | struct GNUNET_FS_SearchResult *sr = cls; |
235 | sr->availability_trials++; | 237 | sr->availability_trials++; |
236 | sr->availability_success++; | 238 | sr->availability_success++; |
239 | GNUNET_FS_search_result_sync_ (sr); | ||
237 | signal_probe_result (sr); | 240 | signal_probe_result (sr); |
238 | } | 241 | } |
239 | 242 | ||
@@ -327,6 +330,7 @@ GNUNET_FS_search_probe_progress_ (void *cls, | |||
327 | dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time); | 330 | dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time); |
328 | sr->remaining_probe_time = GNUNET_TIME_relative_subtract (sr->remaining_probe_time, | 331 | sr->remaining_probe_time = GNUNET_TIME_relative_subtract (sr->remaining_probe_time, |
329 | dur); | 332 | dur); |
333 | GNUNET_FS_search_result_sync_ (sr); | ||
330 | break; | 334 | break; |
331 | default: | 335 | default: |
332 | GNUNET_break (0); | 336 | GNUNET_break (0); |
@@ -427,6 +431,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, | |||
427 | sr->uri = GNUNET_FS_uri_dup (uri); | 431 | sr->uri = GNUNET_FS_uri_dup (uri); |
428 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 432 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
429 | sr->mandatory_missing = sc->mandatory_count; | 433 | sr->mandatory_missing = sc->mandatory_count; |
434 | sr->key = key; | ||
430 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, | 435 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, |
431 | &key, | 436 | &key, |
432 | sr, | 437 | sr, |
@@ -447,6 +452,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, | |||
447 | notify_client_chk_result (sc, sr); | 452 | notify_client_chk_result (sc, sr); |
448 | else | 453 | else |
449 | notify_client_chk_update (sc, sr); | 454 | notify_client_chk_update (sc, sr); |
455 | GNUNET_FS_search_result_sync_ (sr); | ||
450 | GNUNET_FS_search_start_probe_ (sr); | 456 | GNUNET_FS_search_start_probe_ (sr); |
451 | } | 457 | } |
452 | 458 | ||
@@ -506,10 +512,12 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, | |||
506 | sr->sc = sc; | 512 | sr->sc = sc; |
507 | sr->uri = GNUNET_FS_uri_dup (uri); | 513 | sr->uri = GNUNET_FS_uri_dup (uri); |
508 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 514 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
515 | sr->key = key; | ||
509 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, | 516 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, |
510 | &key, | 517 | &key, |
511 | sr, | 518 | sr, |
512 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 519 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
520 | GNUNET_FS_search_result_sync_ (sr); | ||
513 | GNUNET_FS_search_start_probe_ (sr); | 521 | GNUNET_FS_search_start_probe_ (sr); |
514 | /* notify client */ | 522 | /* notify client */ |
515 | notify_client_chk_result (sc, sr); | 523 | notify_client_chk_result (sc, sr); |
@@ -1090,6 +1098,7 @@ search_start (struct GNUNET_FS_Handle *h, | |||
1090 | GNUNET_free (sc); | 1098 | GNUNET_free (sc); |
1091 | return NULL; | 1099 | return NULL; |
1092 | } | 1100 | } |
1101 | GNUNET_FS_search_sync_ (sc); | ||
1093 | pi.status = GNUNET_FS_STATUS_SEARCH_START; | 1102 | pi.status = GNUNET_FS_STATUS_SEARCH_START; |
1094 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 1103 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
1095 | return sc; | 1104 | return sc; |
@@ -1299,7 +1308,7 @@ GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc) | |||
1299 | if (NULL != sc->client) | 1308 | if (NULL != sc->client) |
1300 | GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); | 1309 | GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); |
1301 | sc->client = NULL; | 1310 | sc->client = NULL; |
1302 | // FIXME: make persistent! | 1311 | GNUNET_FS_search_sync_ (sc); |
1303 | // FIXME: should this freeze all active probes? | 1312 | // FIXME: should this freeze all active probes? |
1304 | pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED; | 1313 | pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED; |
1305 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 1314 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
@@ -1319,7 +1328,7 @@ GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc) | |||
1319 | GNUNET_assert (sc->client == NULL); | 1328 | GNUNET_assert (sc->client == NULL); |
1320 | GNUNET_assert (sc->task == GNUNET_SCHEDULER_NO_TASK); | 1329 | GNUNET_assert (sc->task == GNUNET_SCHEDULER_NO_TASK); |
1321 | do_reconnect (sc, NULL); | 1330 | do_reconnect (sc, NULL); |
1322 | // FIXME: make persistent! | 1331 | GNUNET_FS_search_sync_ (sc); |
1323 | pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED; | 1332 | pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED; |
1324 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 1333 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
1325 | } | 1334 | } |
@@ -1395,10 +1404,14 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | |||
1395 | struct GNUNET_FS_ProgressInfo pi; | 1404 | struct GNUNET_FS_ProgressInfo pi; |
1396 | unsigned int i; | 1405 | unsigned int i; |
1397 | struct GNUNET_FS_SearchContext *parent; | 1406 | struct GNUNET_FS_SearchContext *parent; |
1407 | int had_result; | ||
1398 | 1408 | ||
1399 | if (sc->top != NULL) | 1409 | if (sc->top != NULL) |
1400 | GNUNET_FS_end_top (sc->h, sc->top); | 1410 | GNUNET_FS_end_top (sc->h, sc->top); |
1401 | // FIXME: make un-persistent! | 1411 | if (sc->serialization != NULL) |
1412 | GNUNET_FS_remove_sync_file_ (sc->h, | ||
1413 | (sc->parent != NULL) ? "search-children" : "search", | ||
1414 | sc->serialization); | ||
1402 | if (NULL != (parent = sc->parent)) | 1415 | if (NULL != (parent = sc->parent)) |
1403 | { | 1416 | { |
1404 | GNUNET_CONTAINER_DLL_remove (parent->child_head, | 1417 | GNUNET_CONTAINER_DLL_remove (parent->child_head, |
@@ -1408,9 +1421,12 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | |||
1408 | } | 1421 | } |
1409 | while (NULL != sc->child_head) | 1422 | while (NULL != sc->child_head) |
1410 | GNUNET_FS_search_stop (sc->child_head); | 1423 | GNUNET_FS_search_stop (sc->child_head); |
1424 | had_result = (0 != GNUNET_CONTAINER_multihashmap_size (sc->master_result_map)) ? GNUNET_YES : GNUNET_NO; | ||
1411 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | 1425 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, |
1412 | &search_result_free, | 1426 | &search_result_free, |
1413 | sc); | 1427 | sc); |
1428 | if (had_result) | ||
1429 | GNUNET_FS_remove_sync_dir_ (sc->h, "search-results", sc->serialization); | ||
1414 | pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED; | 1430 | pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED; |
1415 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 1431 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
1416 | GNUNET_break (NULL == sc->client_info); | 1432 | GNUNET_break (NULL == sc->client_info); |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index c79b3413e..9d14bb0cb 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -142,14 +142,13 @@ unindex_progress (void *cls, | |||
142 | * @param emsg the error message | 142 | * @param emsg the error message |
143 | */ | 143 | */ |
144 | static void | 144 | static void |
145 | signal_unindex_error (struct GNUNET_FS_UnindexContext *uc, | 145 | signal_unindex_error (struct GNUNET_FS_UnindexContext *uc) |
146 | const char *emsg) | ||
147 | { | 146 | { |
148 | struct GNUNET_FS_ProgressInfo pi; | 147 | struct GNUNET_FS_ProgressInfo pi; |
149 | 148 | ||
150 | pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR; | 149 | pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR; |
151 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 150 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
152 | pi.value.unindex.specifics.error.message = emsg; | 151 | pi.value.unindex.specifics.error.message = uc->emsg; |
153 | GNUNET_FS_unindex_make_status_ (&pi, uc, 0); | 152 | GNUNET_FS_unindex_make_status_ (&pi, uc, 0); |
154 | } | 153 | } |
155 | 154 | ||
@@ -170,11 +169,10 @@ process_cont (void *cls, | |||
170 | struct GNUNET_FS_UnindexContext *uc = cls; | 169 | struct GNUNET_FS_UnindexContext *uc = cls; |
171 | if (success == GNUNET_SYSERR) | 170 | if (success == GNUNET_SYSERR) |
172 | { | 171 | { |
173 | signal_unindex_error (uc, | 172 | uc->emsg = GNUNET_strdup (msg); |
174 | msg); | 173 | signal_unindex_error (uc); |
175 | return; | 174 | return; |
176 | } | 175 | } |
177 | |||
178 | GNUNET_FS_tree_encoder_next (uc->tc); | 176 | GNUNET_FS_tree_encoder_next (uc->tc); |
179 | } | 177 | } |
180 | 178 | ||
@@ -254,8 +252,8 @@ unindex_finish (void *cls, | |||
254 | uc->dsh = NULL; | 252 | uc->dsh = NULL; |
255 | if (emsg != NULL) | 253 | if (emsg != NULL) |
256 | { | 254 | { |
257 | signal_unindex_error (uc, emsg); | 255 | uc->emsg = emsg; |
258 | GNUNET_free (emsg); | 256 | signal_unindex_error (uc); |
259 | } | 257 | } |
260 | else | 258 | else |
261 | { | 259 | { |
@@ -263,6 +261,7 @@ unindex_finish (void *cls, | |||
263 | pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; | 261 | pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; |
264 | GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); | 262 | GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); |
265 | } | 263 | } |
264 | GNUNET_FS_unindex_sync_ (uc); | ||
266 | } | 265 | } |
267 | 266 | ||
268 | 267 | ||
@@ -292,18 +291,21 @@ process_fs_response (void *cls, | |||
292 | if (NULL == msg) | 291 | if (NULL == msg) |
293 | { | 292 | { |
294 | uc->state = UNINDEX_STATE_ERROR; | 293 | uc->state = UNINDEX_STATE_ERROR; |
295 | signal_unindex_error (uc, | 294 | uc->emsg = GNUNET_strdup (_("Timeout waiting for `fs' service.")); |
296 | _("Timeout waiting for `fs' service.")); | 295 | GNUNET_FS_unindex_sync_ (uc); |
296 | signal_unindex_error (uc); | ||
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | if (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK) | 299 | if (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK) |
300 | { | 300 | { |
301 | uc->state = UNINDEX_STATE_ERROR; | 301 | uc->state = UNINDEX_STATE_ERROR; |
302 | signal_unindex_error (uc, | 302 | uc->emsg = GNUNET_strdup (_("Invalid response from `fs' service.")); |
303 | _("Invalid response from `fs' service.")); | 303 | GNUNET_FS_unindex_sync_ (uc); |
304 | signal_unindex_error (uc); | ||
304 | return; | 305 | return; |
305 | } | 306 | } |
306 | uc->state = UNINDEX_STATE_DS_REMOVE; | 307 | uc->state = UNINDEX_STATE_DS_REMOVE; |
308 | GNUNET_FS_unindex_sync_ (uc); | ||
307 | GNUNET_FS_unindex_do_remove_ (uc); | 309 | GNUNET_FS_unindex_do_remove_ (uc); |
308 | } | 310 | } |
309 | 311 | ||
@@ -321,8 +323,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) | |||
321 | if (NULL == uc->dsh) | 323 | if (NULL == uc->dsh) |
322 | { | 324 | { |
323 | uc->state = UNINDEX_STATE_ERROR; | 325 | uc->state = UNINDEX_STATE_ERROR; |
324 | signal_unindex_error (uc, | 326 | uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service.")); |
325 | _("Failed to connect to `datastore' service.")); | 327 | GNUNET_FS_unindex_sync_ (uc); |
328 | signal_unindex_error (uc); | ||
326 | return; | 329 | return; |
327 | } | 330 | } |
328 | uc->fh = GNUNET_DISK_file_open (uc->filename, | 331 | uc->fh = GNUNET_DISK_file_open (uc->filename, |
@@ -333,8 +336,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) | |||
333 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); | 336 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); |
334 | uc->dsh = NULL; | 337 | uc->dsh = NULL; |
335 | uc->state = UNINDEX_STATE_ERROR; | 338 | uc->state = UNINDEX_STATE_ERROR; |
336 | signal_unindex_error (uc, | 339 | uc->emsg = GNUNET_strdup (_("Failed to open file for unindexing.")); |
337 | _("Failed to open file for unindexing.")); | 340 | GNUNET_FS_unindex_sync_ (uc); |
341 | signal_unindex_error (uc); | ||
338 | return; | 342 | return; |
339 | } | 343 | } |
340 | uc->tc = GNUNET_FS_tree_encoder_create (uc->h, | 344 | uc->tc = GNUNET_FS_tree_encoder_create (uc->h, |
@@ -370,12 +374,14 @@ GNUNET_FS_unindex_process_hash_ (void *cls, | |||
370 | if (file_id == NULL) | 374 | if (file_id == NULL) |
371 | { | 375 | { |
372 | uc->state = UNINDEX_STATE_ERROR; | 376 | uc->state = UNINDEX_STATE_ERROR; |
373 | signal_unindex_error (uc, | 377 | uc->emsg = GNUNET_strdup (_("Failed to compute hash of file.")); |
374 | _("Failed to compute hash of file.")); | 378 | GNUNET_FS_unindex_sync_ (uc); |
379 | signal_unindex_error (uc); | ||
375 | return; | 380 | return; |
376 | } | 381 | } |
377 | uc->file_id = *file_id; | 382 | uc->file_id = *file_id; |
378 | uc->state = UNINDEX_STATE_FS_NOTIFY; | 383 | uc->state = UNINDEX_STATE_FS_NOTIFY; |
384 | GNUNET_FS_unindex_sync_ (uc); | ||
379 | uc->client = GNUNET_CLIENT_connect (uc->h->sched, | 385 | uc->client = GNUNET_CLIENT_connect (uc->h->sched, |
380 | "fs", | 386 | "fs", |
381 | uc->h->cfg); | 387 | uc->h->cfg); |
@@ -445,8 +451,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, | |||
445 | ret->start_time = GNUNET_TIME_absolute_get (); | 451 | ret->start_time = GNUNET_TIME_absolute_get (); |
446 | ret->file_size = size; | 452 | ret->file_size = size; |
447 | ret->client_info = cctx; | 453 | ret->client_info = cctx; |
448 | 454 | GNUNET_FS_unindex_sync_ (ret); | |
449 | // FIXME: make persistent! | ||
450 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; | 455 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; |
451 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 456 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
452 | GNUNET_FS_unindex_make_status_ (&pi, ret, 0); | 457 | GNUNET_FS_unindex_make_status_ (&pi, ret, 0); |
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 047c314e4..068095269 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c | |||
@@ -193,6 +193,9 @@ progress_cb (void *cls, | |||
193 | &abort_download_task, | 193 | &abort_download_task, |
194 | NULL); | 194 | NULL); |
195 | break; | 195 | break; |
196 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | ||
197 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: | ||
198 | break; | ||
196 | case GNUNET_FS_STATUS_PUBLISH_START: | 199 | case GNUNET_FS_STATUS_PUBLISH_START: |
197 | GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); | 200 | GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); |
198 | GNUNET_assert (NULL == event->value.publish.pctx); | 201 | GNUNET_assert (NULL == event->value.publish.pctx); |