aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-09-20 01:04:17 +0200
committerJulius Bünger <buenger@mytum.de>2018-09-20 01:07:53 +0200
commit69f439525cabfd0b65d5875e49d306588587cb23 (patch)
treeba8200ce6dbb264021f42e05f2d119aa9e4917aa /src
parentc50386476c7a79efd87d4b1b36f9c740d74dd9f8 (diff)
downloadgnunet-69f439525cabfd0b65d5875e49d306588587cb23.tar.gz
gnunet-69f439525cabfd0b65d5875e49d306588587cb23.zip
Be a little bit more consistent in style
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c20
-rw-r--r--src/rps/gnunet-service-rps_sampler.c22
-rw-r--r--src/rps/gnunet-service-rps_sampler.h8
-rw-r--r--src/rps/rps_api.c16
4 files changed, 37 insertions, 29 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index ec6c651d9..40f576d3e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2347,9 +2347,9 @@ clients_notify_stream_peer (uint64_t num_peers,
2347 * Put random peer from sampler into the view as history update. 2347 * Put random peer from sampler into the view as history update.
2348 */ 2348 */
2349static void 2349static void
2350hist_update (void *cls, 2350hist_update (const struct GNUNET_PeerIdentity *ids,
2351 struct GNUNET_PeerIdentity *ids, 2351 uint32_t num_peers,
2352 uint32_t num_peers) 2352 void *cls)
2353{ 2353{
2354 unsigned int i; 2354 unsigned int i;
2355 (void) cls; 2355 (void) cls;
@@ -2852,9 +2852,9 @@ nse_callback (void *cls,
2852 * Sends those to the requesting client. 2852 * Sends those to the requesting client.
2853 */ 2853 */
2854static void 2854static void
2855client_respond (void *cls, 2855client_respond (const struct GNUNET_PeerIdentity *peer_ids,
2856 struct GNUNET_PeerIdentity *peer_ids, 2856 uint32_t num_peers,
2857 uint32_t num_peers) 2857 void *cls)
2858{ 2858{
2859 struct ReplyCls *reply_cls = cls; 2859 struct ReplyCls *reply_cls = cls;
2860 uint32_t i; 2860 uint32_t i;
@@ -2937,9 +2937,9 @@ handle_client_request (void *cls,
2937 reply_cls->id = ntohl (msg->id); 2937 reply_cls->id = ntohl (msg->id);
2938 reply_cls->cli_ctx = cli_ctx; 2938 reply_cls->cli_ctx = cli_ctx;
2939 reply_cls->req_handle = RPS_sampler_get_n_rand_peers (client_sampler, 2939 reply_cls->req_handle = RPS_sampler_get_n_rand_peers (client_sampler,
2940 num_peers,
2940 client_respond, 2941 client_respond,
2941 reply_cls, 2942 reply_cls);
2942 num_peers);
2943 2943
2944 GNUNET_assert (NULL != cli_ctx); 2944 GNUNET_assert (NULL != cli_ctx);
2945 GNUNET_CONTAINER_DLL_insert (cli_ctx->rep_cls_head, 2945 GNUNET_CONTAINER_DLL_insert (cli_ctx->rep_cls_head,
@@ -3894,9 +3894,9 @@ do_round (void *cls)
3894 3894
3895 /* Update view with peers from history */ 3895 /* Update view with peers from history */
3896 RPS_sampler_get_n_rand_peers (prot_sampler, 3896 RPS_sampler_get_n_rand_peers (prot_sampler,
3897 final_size - second_border,
3897 hist_update, 3898 hist_update,
3898 NULL, 3899 NULL);
3899 final_size - second_border);
3900 // TODO change the peer_flags accordingly 3900 // TODO change the peer_flags accordingly
3901 3901
3902 for (i = 0; i < View_size (); i++) 3902 for (i = 0; i < View_size (); i++)
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index fdd500aa1..0de15bbc0 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -272,7 +272,7 @@ check_n_peers_ready (void *cls,
272 LOG (GNUNET_ERROR_TYPE_DEBUG, 272 LOG (GNUNET_ERROR_TYPE_DEBUG,
273 "returning %" PRIX32 " peers to the client\n", 273 "returning %" PRIX32 " peers to the client\n",
274 req_handle->num_peers); 274 req_handle->num_peers);
275 req_handle->callback (req_handle->cls, req_handle->ids, req_handle->num_peers); 275 req_handle->callback (req_handle->ids, req_handle->num_peers, req_handle->cls);
276 276
277 RPS_sampler_request_cancel (req_handle); 277 RPS_sampler_request_cancel (req_handle);
278 } 278 }
@@ -647,14 +647,14 @@ sampler_mod_get_rand_peer (void *cls)
647 } 647 }
648 /* More reasons to wait could be added here */ 648 /* More reasons to wait could be added here */
649 649
650 GNUNET_STATISTICS_set (stats, 650// GNUNET_STATISTICS_set (stats,
651 "# client sampler element input", 651// "# client sampler element input",
652 s_elem->num_peers, 652// s_elem->num_peers,
653 GNUNET_NO); 653// GNUNET_NO);
654 GNUNET_STATISTICS_set (stats, 654// GNUNET_STATISTICS_set (stats,
655 "# client sampler element change", 655// "# client sampler element change",
656 s_elem->num_change, 656// s_elem->num_change,
657 GNUNET_NO); 657// GNUNET_NO);
658 658
659 RPS_sampler_elem_reinit (s_elem); 659 RPS_sampler_elem_reinit (s_elem);
660 s_elem->last_client_request = GNUNET_TIME_absolute_get (); 660 s_elem->last_client_request = GNUNET_TIME_absolute_get ();
@@ -683,9 +683,9 @@ sampler_mod_get_rand_peer (void *cls)
683 */ 683 */
684struct RPS_SamplerRequestHandle * 684struct RPS_SamplerRequestHandle *
685RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, 685RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler,
686 uint32_t num_peers,
686 RPS_sampler_n_rand_peers_ready_cb cb, 687 RPS_sampler_n_rand_peers_ready_cb cb,
687 void *cls, 688 void *cls)
688 uint32_t num_peers)
689{ 689{
690 uint32_t i; 690 uint32_t i;
691 struct RPS_SamplerRequestHandle *req_handle; 691 struct RPS_SamplerRequestHandle *req_handle;
diff --git a/src/rps/gnunet-service-rps_sampler.h b/src/rps/gnunet-service-rps_sampler.h
index c44844f96..6b386596f 100644
--- a/src/rps/gnunet-service-rps_sampler.h
+++ b/src/rps/gnunet-service-rps_sampler.h
@@ -46,8 +46,9 @@ struct RPS_SamplerRequestHandle;
46 * to be freed 46 * to be freed
47 */ 47 */
48 typedef void 48 typedef void
49(*RPS_sampler_n_rand_peers_ready_cb) (void *cls, 49(*RPS_sampler_n_rand_peers_ready_cb) (const struct GNUNET_PeerIdentity *ids,
50 struct GNUNET_PeerIdentity *ids, uint32_t num_peers); 50 uint32_t num_peers,
51 void *cls);
51 52
52 53
53/** 54/**
@@ -135,8 +136,9 @@ RPS_sampler_reinitialise_by_value (struct RPS_Sampler *sampler,
135 */ 136 */
136struct RPS_SamplerRequestHandle * 137struct RPS_SamplerRequestHandle *
137RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, 138RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler,
139 uint32_t num_peers,
138 RPS_sampler_n_rand_peers_ready_cb cb, 140 RPS_sampler_n_rand_peers_ready_cb cb,
139 void *cls, uint32_t num_peers); 141 void *cls);
140 142
141/** 143/**
142 * Cancle a request issued through #RPS_sampler_n_rand_peers_ready_cb. 144 * Cancle a request issued through #RPS_sampler_n_rand_peers_ready_cb.
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 00f817468..7afe21d3a 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -78,7 +78,7 @@ struct GNUNET_RPS_Handle
78 78
79 79
80/** 80/**
81 * Handler to single requests from the client. 81 * Handler for a single request from a client.
82 */ 82 */
83struct GNUNET_RPS_Request_Handle 83struct GNUNET_RPS_Request_Handle
84{ 84{
@@ -95,7 +95,12 @@ struct GNUNET_RPS_Request_Handle
95 /** 95 /**
96 * The number of requested peers. 96 * The number of requested peers.
97 */ 97 */
98 uint32_t num_peers; 98 uint32_t num_requests;
99
100 /**
101 * @brief The Sampler for the client request
102 */
103 struct RPS_Sampler *sampler;
99 104
100 /** 105 /**
101 * The callback to be called when we receive an answer. 106 * The callback to be called when we receive an answer.
@@ -131,6 +136,7 @@ struct cb_cls_pack
131 struct GNUNET_CLIENT_Connection *service_conn; 136 struct GNUNET_CLIENT_Connection *service_conn;
132}; 137};
133 138
139
134/** 140/**
135 * @brief Send a request to the service. 141 * @brief Send a request to the service.
136 * 142 *
@@ -170,7 +176,7 @@ resend_requests_iterator (void *cls, uint32_t key, void *value)
170 const struct GNUNET_RPS_Request_Handle *req_handle = value; 176 const struct GNUNET_RPS_Request_Handle *req_handle = value;
171 (void) key; 177 (void) key;
172 178
173 send_request (h, req_handle->id, req_handle->num_peers); 179 send_request (h, req_handle->id, req_handle->num_requests);
174 return GNUNET_YES; /* continue iterating */ 180 return GNUNET_YES; /* continue iterating */
175} 181}
176 182
@@ -248,7 +254,7 @@ handle_reply (void *cls,
248 GNUNET_CONTAINER_multihashmap32_contains (h->req_handlers, id)); 254 GNUNET_CONTAINER_multihashmap32_contains (h->req_handlers, id));
249 rh = GNUNET_CONTAINER_multihashmap32_get (h->req_handlers, id); 255 rh = GNUNET_CONTAINER_multihashmap32_get (h->req_handlers, id);
250 GNUNET_assert (NULL != rh); 256 GNUNET_assert (NULL != rh);
251 GNUNET_assert (rh->num_peers == ntohl (msg->num_peers)); 257 GNUNET_assert (rh->num_requests == ntohl (msg->num_peers));
252 GNUNET_CONTAINER_multihashmap32_remove_all (h->req_handlers, id); 258 GNUNET_CONTAINER_multihashmap32_remove_all (h->req_handlers, id);
253 rh->ready_cb (rh->ready_cb_cls, 259 rh->ready_cb (rh->ready_cb_cls,
254 ntohl (msg->num_peers), 260 ntohl (msg->num_peers),
@@ -422,7 +428,7 @@ handle_stream_input (void *cls,
422 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 428 peers = (struct GNUNET_PeerIdentity *) &msg[1];
423 GNUNET_assert (NULL != h); 429 GNUNET_assert (NULL != h);
424 GNUNET_assert (NULL != h->stream_input_cb); 430 GNUNET_assert (NULL != h->stream_input_cb);
425 h->stream_input_cb (h->stream_input_cb, ntohl (msg->num_peers), peers); 431 h->stream_input_cb (h->stream_input_cls, ntohl (msg->num_peers), peers);
426} 432}
427 433
428 434