aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-service-rps.c')
-rw-r--r--src/rps/gnunet-service-rps.c61
1 files changed, 16 insertions, 45 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 40f576d3e..862514264 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -47,8 +47,6 @@
47 47
48// TODO connect to friends 48// TODO connect to friends
49 49
50// TODO store peers somewhere persistent
51
52// TODO blacklist? (-> mal peer detection on top of brahms) 50// TODO blacklist? (-> mal peer detection on top of brahms)
53 51
54// hist_size_init, hist_size_max 52// hist_size_init, hist_size_max
@@ -978,7 +976,6 @@ destroy_peer (struct PeerContext *peer_ctx)
978 peer_ctx->liveliness_check_pending, 976 peer_ctx->liveliness_check_pending,
979 sizeof (struct PendingMessage))) ) 977 sizeof (struct PendingMessage))) )
980 { 978 {
981 // TODO this may leak memory
982 peer_ctx->liveliness_check_pending = NULL; 979 peer_ctx->liveliness_check_pending = NULL;
983 GNUNET_STATISTICS_update (stats, 980 GNUNET_STATISTICS_update (stats,
984 "# pending liveliness checks", 981 "# pending liveliness checks",
@@ -1620,10 +1617,6 @@ check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
1620 * @brief Destroy the send channel of a peer e.g. stop indicating a sending 1617 * @brief Destroy the send channel of a peer e.g. stop indicating a sending
1621 * intention to another peer 1618 * intention to another peer
1622 * 1619 *
1623 * If there is also no channel to receive messages from that peer, remove it
1624 * from the peermap.
1625 * TODO really?
1626 *
1627 * @peer the peer identity of the peer whose sending channel to destroy 1620 * @peer the peer identity of the peer whose sending channel to destroy
1628 * @return #GNUNET_YES if channel was destroyed 1621 * @return #GNUNET_YES if channel was destroyed
1629 * #GNUNET_NO otherwise 1622 * #GNUNET_NO otherwise
@@ -1777,10 +1770,10 @@ struct ClientContext
1777 int64_t view_updates_left; 1770 int64_t view_updates_left;
1778 1771
1779 /** 1772 /**
1780 * @brief How many peers from the biased 1773 * @brief Whether this client wants to receive stream updates.
1781 * stream this client expects to receive. 1774 * Either #GNUNET_YES or #GNUNET_NO
1782 */ 1775 */
1783 int64_t stream_peers_left; 1776 int8_t stream_update;
1784 1777
1785 /** 1778 /**
1786 * The client handle to send the reply to 1779 * The client handle to send the reply to
@@ -2232,9 +2225,9 @@ send_view (const struct ClientContext *cli_ctx,
2232 * @param view_size the size of the view array (can be 0) 2225 * @param view_size the size of the view array (can be 0)
2233 */ 2226 */
2234void 2227void
2235send_stream_peer (const struct ClientContext *cli_ctx, 2228send_stream_peers (const struct ClientContext *cli_ctx,
2236 uint64_t num_peers, 2229 uint64_t num_peers,
2237 const struct GNUNET_PeerIdentity *peers) 2230 const struct GNUNET_PeerIdentity *peers)
2238{ 2231{
2239 struct GNUNET_MQ_Envelope *ev; 2232 struct GNUNET_MQ_Envelope *ev;
2240 struct GNUNET_RPS_CS_DEBUG_StreamReply *out_msg; 2233 struct GNUNET_RPS_CS_DEBUG_StreamReply *out_msg;
@@ -2275,7 +2268,7 @@ clients_notify_view_update (void)
2275 2268
2276 for (cli_ctx_iter = cli_ctx_head; 2269 for (cli_ctx_iter = cli_ctx_head;
2277 NULL != cli_ctx_iter; 2270 NULL != cli_ctx_iter;
2278 cli_ctx_iter = cli_ctx_head->next) 2271 cli_ctx_iter = cli_ctx_iter->next)
2279 { 2272 {
2280 if (1 < cli_ctx_iter->view_updates_left) 2273 if (1 < cli_ctx_iter->view_updates_left)
2281 { 2274 {
@@ -2306,7 +2299,6 @@ clients_notify_stream_peer (uint64_t num_peers,
2306 // TODO enum StreamPeerSource) 2299 // TODO enum StreamPeerSource)
2307{ 2300{
2308 struct ClientContext *cli_ctx_iter; 2301 struct ClientContext *cli_ctx_iter;
2309 uint64_t num_peers_send;
2310 2302
2311 LOG (GNUNET_ERROR_TYPE_DEBUG, 2303 LOG (GNUNET_ERROR_TYPE_DEBUG,
2312 "Got peer (%s) from biased stream - update all clients\n", 2304 "Got peer (%s) from biased stream - update all clients\n",
@@ -2314,32 +2306,12 @@ clients_notify_stream_peer (uint64_t num_peers,
2314 2306
2315 for (cli_ctx_iter = cli_ctx_head; 2307 for (cli_ctx_iter = cli_ctx_head;
2316 NULL != cli_ctx_iter; 2308 NULL != cli_ctx_iter;
2317 cli_ctx_iter = cli_ctx_head->next) 2309 cli_ctx_iter = cli_ctx_iter->next)
2318 { 2310 {
2319 if (0 < cli_ctx_iter->stream_peers_left) 2311 if (GNUNET_YES == cli_ctx_iter->stream_update)
2320 {
2321 /* Client wants to receive limited amount of updates */
2322 if (num_peers > cli_ctx_iter->stream_peers_left)
2323 {
2324 num_peers_send = num_peers - cli_ctx_iter->stream_peers_left;
2325 cli_ctx_iter->stream_peers_left = 0;
2326 }
2327 else
2328 {
2329 num_peers_send = cli_ctx_iter->stream_peers_left - num_peers;
2330 cli_ctx_iter->stream_peers_left -= num_peers_send;
2331 }
2332 } else if (0 > cli_ctx_iter->stream_peers_left)
2333 {
2334 /* Client is not interested in updates */
2335 continue;
2336 } else /* _updates_left == 0 - infinite amount of updates */
2337 { 2312 {
2338 num_peers_send = num_peers; 2313 send_stream_peers (cli_ctx_iter, num_peers, peers);
2339 } 2314 }
2340
2341 /* send view */
2342 send_stream_peer (cli_ctx_iter, num_peers_send, peers);
2343 } 2315 }
2344} 2316}
2345 2317
@@ -3076,16 +3048,13 @@ handle_client_stream_request (void *cls,
3076 const struct GNUNET_RPS_CS_DEBUG_StreamRequest *msg) 3048 const struct GNUNET_RPS_CS_DEBUG_StreamRequest *msg)
3077{ 3049{
3078 struct ClientContext *cli_ctx = cls; 3050 struct ClientContext *cli_ctx = cls;
3079 uint64_t num_peers; 3051 (void) msg;
3080
3081 num_peers = ntohl (msg->num_peers);
3082 3052
3083 LOG (GNUNET_ERROR_TYPE_DEBUG, 3053 LOG (GNUNET_ERROR_TYPE_DEBUG,
3084 "Client requested %" PRIu64 " peers from biased stream.\n", 3054 "Client requested peers from biased stream.\n");
3085 num_peers); 3055 cli_ctx->stream_update = GNUNET_YES;
3086 3056
3087 GNUNET_assert (NULL != cli_ctx); 3057 GNUNET_assert (NULL != cli_ctx);
3088 cli_ctx->stream_peers_left = num_peers;
3089 GNUNET_SERVICE_client_continue (cli_ctx->client); 3058 GNUNET_SERVICE_client_continue (cli_ctx->client);
3090} 3059}
3091 3060
@@ -3882,7 +3851,8 @@ do_round (void *cls)
3882 if (GNUNET_OK == inserted) 3851 if (GNUNET_OK == inserted)
3883 { 3852 {
3884 clients_notify_stream_peer (1, 3853 clients_notify_stream_peer (1,
3885 CustomPeerMap_get_peer_by_index (push_map, permut[i])); 3854 CustomPeerMap_get_peer_by_index (pull_map,
3855 permut[i - first_border]));
3886 } 3856 }
3887 to_file (file_name_view_log, 3857 to_file (file_name_view_log,
3888 "+%s\t(pull list)", 3858 "+%s\t(pull list)",
@@ -4195,6 +4165,7 @@ client_connect_cb (void *cls,
4195 cli_ctx = GNUNET_new (struct ClientContext); 4165 cli_ctx = GNUNET_new (struct ClientContext);
4196 cli_ctx->mq = mq; 4166 cli_ctx->mq = mq;
4197 cli_ctx->view_updates_left = -1; 4167 cli_ctx->view_updates_left = -1;
4168 cli_ctx->stream_update = GNUNET_NO;
4198 cli_ctx->client = client; 4169 cli_ctx->client = client;
4199 GNUNET_CONTAINER_DLL_insert (cli_ctx_head, 4170 GNUNET_CONTAINER_DLL_insert (cli_ctx_head,
4200 cli_ctx_tail, 4171 cli_ctx_tail,