diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-18 09:00:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-18 09:00:05 +0000 |
commit | 53840e9a81994acd8dc4c0cb1c54a0d4764667c3 (patch) | |
tree | 317eb98e7e6ab6472d5700c0db2de84913489bce /src/fs | |
parent | e67ade17fc2bf555af625863dab525f909b310f2 (diff) | |
download | gnunet-53840e9a81994acd8dc4c0cb1c54a0d4764667c3.tar.gz gnunet-53840e9a81994acd8dc4c0cb1c54a0d4764667c3.zip |
making peer_configure API cancellable
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index ed68dcc4a..7a8c0ad33 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -417,6 +417,11 @@ struct PendingRequest | |||
417 | struct GNUNET_CONTAINER_BloomFilter *bf; | 417 | struct GNUNET_CONTAINER_BloomFilter *bf; |
418 | 418 | ||
419 | /** | 419 | /** |
420 | * Context of our GNUNET_CORE_peer_get_info call. | ||
421 | */ | ||
422 | struct GNUNET_CORE_InformationRequestContext *irc; | ||
423 | |||
424 | /** | ||
420 | * Replies that we have received but were unable to forward yet | 425 | * Replies that we have received but were unable to forward yet |
421 | * (typically non-null only if we have a pending transmission | 426 | * (typically non-null only if we have a pending transmission |
422 | * request with the client or the respective peer). | 427 | * request with the client or the respective peer). |
@@ -1787,6 +1792,7 @@ target_reservation_cb (void *cls, | |||
1787 | uint16_t size; | 1792 | uint16_t size; |
1788 | struct GNUNET_TIME_Relative maxdelay; | 1793 | struct GNUNET_TIME_Relative maxdelay; |
1789 | 1794 | ||
1795 | pr->irc = NULL; | ||
1790 | GNUNET_assert (peer != NULL); | 1796 | GNUNET_assert (peer != NULL); |
1791 | if ( (amount != DBLOCK_SIZE) || | 1797 | if ( (amount != DBLOCK_SIZE) || |
1792 | (pr->cth != NULL) ) | 1798 | (pr->cth != NULL) ) |
@@ -1865,17 +1871,15 @@ forward_request_task (void *cls, | |||
1865 | return; | 1871 | return; |
1866 | } | 1872 | } |
1867 | /* (2) reserve reply bandwidth */ | 1873 | /* (2) reserve reply bandwidth */ |
1868 | // FIXME: need a way to cancel; this | 1874 | GNUNET_assert (NULL == pr->irc); |
1869 | // async operation is problematic (segv-problematic) | 1875 | pr->irc = GNUNET_CORE_peer_get_info (sched, cfg, |
1870 | // if "pr" is destroyed while it happens! | 1876 | &psc.target, |
1871 | GNUNET_CORE_peer_configure (core, | 1877 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1872 | &psc.target, | 1878 | -1, |
1873 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1879 | DBLOCK_SIZE, // FIXME: make dependent on type? |
1874 | -1, | 1880 | 0, |
1875 | DBLOCK_SIZE, // FIXME: make dependent on type? | 1881 | &target_reservation_cb, |
1876 | 0, | 1882 | pr); |
1877 | &target_reservation_cb, | ||
1878 | pr); | ||
1879 | } | 1883 | } |
1880 | 1884 | ||
1881 | 1885 | ||
@@ -2216,6 +2220,11 @@ destroy_pending_request (struct PendingRequest *pr) | |||
2216 | pr); | 2220 | pr); |
2217 | // FIXME: not sure how this can work (efficiently) | 2221 | // FIXME: not sure how this can work (efficiently) |
2218 | // also, what does the return value mean? | 2222 | // also, what does the return value mean? |
2223 | if (pr->irc != NULL) | ||
2224 | { | ||
2225 | GNUNET_CORE_peer_get_info_cancel (pr->irc); | ||
2226 | pr->irc = NULL; | ||
2227 | } | ||
2219 | if (pr->client == NULL) | 2228 | if (pr->client == NULL) |
2220 | { | 2229 | { |
2221 | GNUNET_CONTAINER_heap_remove_node (requests_by_expiration, | 2230 | GNUNET_CONTAINER_heap_remove_node (requests_by_expiration, |
@@ -2914,10 +2923,10 @@ handle_p2p_get (void *cls, | |||
2914 | if (preference < QUERY_BANDWIDTH_VALUE) | 2923 | if (preference < QUERY_BANDWIDTH_VALUE) |
2915 | preference = QUERY_BANDWIDTH_VALUE; | 2924 | preference = QUERY_BANDWIDTH_VALUE; |
2916 | // FIXME: also reserve bandwidth for reply? | 2925 | // FIXME: also reserve bandwidth for reply? |
2917 | GNUNET_CORE_peer_configure (core, | 2926 | (void) GNUNET_CORE_peer_get_info (sched, cfg, |
2918 | other, | 2927 | other, |
2919 | GNUNET_TIME_UNIT_FOREVER_REL, | 2928 | GNUNET_TIME_UNIT_FOREVER_REL, |
2920 | 0, 0, preference, NULL, NULL); | 2929 | 0, 0, preference, NULL, NULL); |
2921 | if (0 != (pgc->policy & ROUTING_POLICY_ANSWER)) | 2930 | if (0 != (pgc->policy & ROUTING_POLICY_ANSWER)) |
2922 | pgc->drq = queue_ds_request (BASIC_DATASTORE_REQUEST_DELAY, | 2931 | pgc->drq = queue_ds_request (BASIC_DATASTORE_REQUEST_DELAY, |
2923 | &ds_get_request, | 2932 | &ds_get_request, |
@@ -3318,7 +3327,6 @@ run (void *cls, | |||
3318 | NULL, | 3327 | NULL, |
3319 | &peer_connect_handler, | 3328 | &peer_connect_handler, |
3320 | &peer_disconnect_handler, | 3329 | &peer_disconnect_handler, |
3321 | NULL, | ||
3322 | NULL, GNUNET_NO, | 3330 | NULL, GNUNET_NO, |
3323 | NULL, GNUNET_NO, | 3331 | NULL, GNUNET_NO, |
3324 | p2p_handlers); | 3332 | p2p_handlers); |