diff options
author | Julius Bünger <buenger@mytum.de> | 2018-09-26 21:15:01 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-09-26 21:15:01 +0200 |
commit | cf847c7470937fa160ccec6588acdc3c46c5e202 (patch) | |
tree | 26da6866e88a2569d8d7791484b8470f31d42874 /src | |
parent | 8d45a78fbc09680716aefd858e87f3cfc4363e37 (diff) | |
download | gnunet-cf847c7470937fa160ccec6588acdc3c46c5e202.tar.gz gnunet-cf847c7470937fa160ccec6588acdc3c46c5e202.zip |
Handle cancellation of view updates
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 25 | ||||
-rw-r--r-- | src/rps/rps-sampler_client.c | 1 | ||||
-rw-r--r-- | src/rps/rps_api.c | 21 |
3 files changed, 45 insertions, 2 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 3dd887d47..4e06f5a49 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -2733,6 +2733,27 @@ handle_client_view_request (void *cls, | |||
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | 2735 | ||
2736 | static void | ||
2737 | handle_client_view_request_cancel (void *cls, | ||
2738 | const struct GNUNET_MessageHeader *msg) | ||
2739 | { | ||
2740 | struct ClientContext *cli_ctx = cls; | ||
2741 | uint64_t num_updates; | ||
2742 | |||
2743 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2744 | "Client does not want to receive updates of view any more.\n", | ||
2745 | num_updates); | ||
2746 | |||
2747 | GNUNET_assert (NULL != cli_ctx); | ||
2748 | cli_ctx->view_updates_left = 0; | ||
2749 | if (GNUNET_YES == cli_ctx->stream_update) | ||
2750 | { | ||
2751 | destroy_cli_ctx (cli_ctx); | ||
2752 | } | ||
2753 | GNUNET_SERVICE_client_continue (cli_ctx->client); | ||
2754 | } | ||
2755 | |||
2756 | |||
2736 | /** | 2757 | /** |
2737 | * Handle RPS request for biased stream from the client. | 2758 | * Handle RPS request for biased stream from the client. |
2738 | * | 2759 | * |
@@ -4079,6 +4100,10 @@ GNUNET_SERVICE_MAIN | |||
4079 | GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST, | 4100 | GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST, |
4080 | struct GNUNET_RPS_CS_DEBUG_ViewRequest, | 4101 | struct GNUNET_RPS_CS_DEBUG_ViewRequest, |
4081 | NULL), | 4102 | NULL), |
4103 | GNUNET_MQ_hd_fixed_size (client_view_request_cancel, | ||
4104 | GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL, | ||
4105 | struct GNUNET_MessageHeader, | ||
4106 | NULL), | ||
4082 | GNUNET_MQ_hd_fixed_size (client_stream_request, | 4107 | GNUNET_MQ_hd_fixed_size (client_stream_request, |
4083 | GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST, | 4108 | GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST, |
4084 | struct GNUNET_RPS_CS_DEBUG_StreamRequest, | 4109 | struct GNUNET_RPS_CS_DEBUG_StreamRequest, |
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c index da832a323..4904b9d43 100644 --- a/src/rps/rps-sampler_client.c +++ b/src/rps/rps-sampler_client.c | |||
@@ -201,7 +201,6 @@ RPS_sampler_mod_init (size_t init_size, | |||
201 | max_size = 1000; // TODO make input to _samplers_init() | 201 | max_size = 1000; // TODO make input to _samplers_init() |
202 | 202 | ||
203 | sampler = GNUNET_new (struct RPS_Sampler); | 203 | sampler = GNUNET_new (struct RPS_Sampler); |
204 | |||
205 | sampler->max_round_interval = max_round_interval; | 204 | sampler->max_round_interval = max_round_interval; |
206 | sampler->get_peers = sampler_mod_get_rand_peer; | 205 | sampler->get_peers = sampler_mod_get_rand_peer; |
207 | //sampler->sampler_elements = GNUNET_new_array(init_size, struct GNUNET_PeerIdentity); | 206 | //sampler->sampler_elements = GNUNET_new_array(init_size, struct GNUNET_PeerIdentity); |
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c index 6e124644d..7d0674aff 100644 --- a/src/rps/rps_api.c +++ b/src/rps/rps_api.c | |||
@@ -344,6 +344,20 @@ GNUNET_RPS_view_request (struct GNUNET_RPS_Handle *rps_handle, | |||
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void | ||
348 | GNUNET_RPS_view_request_cancel (struct GNUNET_RPS_Handle *rps_handle) | ||
349 | { | ||
350 | struct GNUNET_MQ_Envelope *ev; | ||
351 | |||
352 | GNUNET_assert (NULL != rps_handle->view_update_cb); | ||
353 | |||
354 | rps_handle->view_update_cb = NULL; | ||
355 | |||
356 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL); | ||
357 | GNUNET_MQ_send (rps_handle->mq, ev); | ||
358 | } | ||
359 | |||
360 | |||
347 | /** | 361 | /** |
348 | * Request biased stream of peers that are being put into the sampler | 362 | * Request biased stream of peers that are being put into the sampler |
349 | * | 363 | * |
@@ -879,7 +893,12 @@ GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h) | |||
879 | if (NULL != h->stream_requests_head) | 893 | if (NULL != h->stream_requests_head) |
880 | { | 894 | { |
881 | LOG (GNUNET_ERROR_TYPE_WARNING, | 895 | LOG (GNUNET_ERROR_TYPE_WARNING, |
882 | "Still waiting for requests\n"); | 896 | "Still waiting for replies\n"); |
897 | } | ||
898 | if (NULL != h->view_update_cb) | ||
899 | { | ||
900 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
901 | "Still waiting for view updates\n"); | ||
883 | } | 902 | } |
884 | GNUNET_free (h); | 903 | GNUNET_free (h); |
885 | } | 904 | } |