diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-03 12:12:38 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-03 12:12:38 +0000 |
commit | 9ae6238e0fb4c09531f5ae8b00f017f90232ab7a (patch) | |
tree | 37357c782f4f5261014d9e226c4b8d9c1ee41285 /src/namestore | |
parent | 8829518fefd8621b85140b794ab33215dc7ee1d8 (diff) | |
download | gnunet-9ae6238e0fb4c09531f5ae8b00f017f90232ab7a.tar.gz gnunet-9ae6238e0fb4c09531f5ae8b00f017f90232ab7a.zip |
- change for 2477
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 99c648741..95ee989d1 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1659,6 +1659,30 @@ handle_zone_to_name (void *cls, | |||
1659 | 1659 | ||
1660 | 1660 | ||
1661 | /** | 1661 | /** |
1662 | * Zone iteration processor result | ||
1663 | */ | ||
1664 | enum ZoneIterationResult | ||
1665 | { | ||
1666 | /** | ||
1667 | * Found records, but all records were filtered | ||
1668 | * Continue to iterate | ||
1669 | */ | ||
1670 | IT_ALL_RECORDS_FILTERED = -1, | ||
1671 | |||
1672 | /** | ||
1673 | * Found records, | ||
1674 | * Continue to iterate with next iteration_next call | ||
1675 | */ | ||
1676 | IT_SUCCESS_MORE_AVAILABLE = 0, | ||
1677 | |||
1678 | /** | ||
1679 | * Iteration complete | ||
1680 | */ | ||
1681 | IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE = 1, | ||
1682 | }; | ||
1683 | |||
1684 | |||
1685 | /** | ||
1662 | * Context for record remove operations passed from | 1686 | * Context for record remove operations passed from |
1663 | * 'run_zone_iteration_round' to 'zone_iteraterate_proc' as closure | 1687 | * 'run_zone_iteration_round' to 'zone_iteraterate_proc' as closure |
1664 | */ | 1688 | */ |
@@ -1670,10 +1694,11 @@ struct ZoneIterationProcResult | |||
1670 | struct GNUNET_NAMESTORE_ZoneIteration *zi; | 1694 | struct GNUNET_NAMESTORE_ZoneIteration *zi; |
1671 | 1695 | ||
1672 | /** | 1696 | /** |
1673 | * Iteration result: iteration done? Set to GNUNET_YES | 1697 | * Iteration result: iteration done? |
1674 | * if there are no further results, GNUNET_NO if there | 1698 | * IT_SUCCESS_MORE_AVAILABLE: if there may be more results overall but |
1675 | * may be more results overall but we got one for now, | 1699 | * we got one for now and have sent it to the client |
1676 | * GNUNET_SYSERR if all results were filtered so far. | 1700 | * IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE: if there are no further results, |
1701 | * IT_ALL_RECORDS_FILTERED: if all results were filtered so far. | ||
1677 | */ | 1702 | */ |
1678 | int res_iteration_finished; | 1703 | int res_iteration_finished; |
1679 | 1704 | ||
@@ -1716,12 +1741,12 @@ zone_iteraterate_proc (void *cls, | |||
1716 | char *name_tmp; | 1741 | char *name_tmp; |
1717 | char *rd_ser; | 1742 | char *rd_ser; |
1718 | 1743 | ||
1719 | proc->res_iteration_finished = GNUNET_NO; | 1744 | proc->res_iteration_finished = IT_SUCCESS_MORE_AVAILABLE; |
1720 | if ((NULL == zone_key) && (NULL == name)) | 1745 | if ((NULL == zone_key) && (NULL == name)) |
1721 | { | 1746 | { |
1722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1723 | "Iteration done\n"); | 1748 | "Iteration done\n"); |
1724 | proc->res_iteration_finished = GNUNET_YES; | 1749 | proc->res_iteration_finished = IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE; |
1725 | return; | 1750 | return; |
1726 | } | 1751 | } |
1727 | if ((NULL == zone_key) || (NULL == name)) | 1752 | if ((NULL == zone_key) || (NULL == name)) |
@@ -1808,6 +1833,14 @@ zone_iteraterate_proc (void *cls, | |||
1808 | } | 1833 | } |
1809 | } | 1834 | } |
1810 | } | 1835 | } |
1836 | if (rd_count_filtered == 0) | ||
1837 | { | ||
1838 | /* After filtering records there are no records left to return */ | ||
1839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No records to transmit\n"); | ||
1840 | proc->res_iteration_finished = IT_ALL_RECORDS_FILTERED; | ||
1841 | return; | ||
1842 | } | ||
1843 | |||
1811 | if (GNUNET_YES == proc->zi->has_zone) | 1844 | if (GNUNET_YES == proc->zi->has_zone) |
1812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1813 | "Sending name `%s' for iteration over zone `%s'\n", | 1846 | "Sending name `%s' for iteration over zone `%s'\n", |
@@ -1843,7 +1876,7 @@ zone_iteraterate_proc (void *cls, | |||
1843 | GNUNET_SERVER_notification_context_unicast (snc, proc->zi->client->client, | 1876 | GNUNET_SERVER_notification_context_unicast (snc, proc->zi->client->client, |
1844 | (const struct GNUNET_MessageHeader *) zir_msg, | 1877 | (const struct GNUNET_MessageHeader *) zir_msg, |
1845 | GNUNET_NO); | 1878 | GNUNET_NO); |
1846 | proc->res_iteration_finished = GNUNET_NO; | 1879 | proc->res_iteration_finished = IT_SUCCESS_MORE_AVAILABLE; |
1847 | GNUNET_free (zir_msg); | 1880 | GNUNET_free (zir_msg); |
1848 | GNUNET_free_non_null (new_signature); | 1881 | GNUNET_free_non_null (new_signature); |
1849 | } | 1882 | } |
@@ -1867,8 +1900,8 @@ run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi) | |||
1867 | zone = &zi->zone; | 1900 | zone = &zi->zone; |
1868 | else | 1901 | else |
1869 | zone = NULL; | 1902 | zone = NULL; |
1870 | proc.res_iteration_finished = GNUNET_SYSERR; | 1903 | proc.res_iteration_finished = IT_ALL_RECORDS_FILTERED; |
1871 | while (GNUNET_SYSERR == proc.res_iteration_finished) | 1904 | while (IT_ALL_RECORDS_FILTERED == proc.res_iteration_finished) |
1872 | { | 1905 | { |
1873 | if (GNUNET_SYSERR == | 1906 | if (GNUNET_SYSERR == |
1874 | GSN_database->iterate_records (GSN_database->cls, zone, NULL, | 1907 | GSN_database->iterate_records (GSN_database->cls, zone, NULL, |
@@ -1880,8 +1913,12 @@ run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi) | |||
1880 | } | 1913 | } |
1881 | zi->offset++; | 1914 | zi->offset++; |
1882 | } | 1915 | } |
1883 | if (GNUNET_YES != proc.res_iteration_finished) | 1916 | if (IT_SUCCESS_MORE_AVAILABLE == proc.res_iteration_finished) |
1917 | { | ||
1918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1919 | "More results available\n"); | ||
1884 | return; /* more results later */ | 1920 | return; /* more results later */ |
1921 | } | ||
1885 | if (GNUNET_YES == zi->has_zone) | 1922 | if (GNUNET_YES == zi->has_zone) |
1886 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1923 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1887 | "No more results for zone `%s'\n", | 1924 | "No more results for zone `%s'\n", |