diff options
-rw-r--r-- | src/rps/gnunet-service-rps.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index f8b2e6f22..da0661b2d 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -62,7 +62,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
62 | /** | 62 | /** |
63 | * Our own identity. | 63 | * Our own identity. |
64 | */ | 64 | */ |
65 | static struct GNUNET_PeerIdentity *own_identity; | 65 | static struct GNUNET_PeerIdentity own_identity; |
66 | 66 | ||
67 | 67 | ||
68 | struct GNUNET_PeerIdentity * | 68 | struct GNUNET_PeerIdentity * |
@@ -732,7 +732,7 @@ resize_wrapper () | |||
732 | 732 | ||
733 | /** | 733 | /** |
734 | * Estimate request rate | 734 | * Estimate request rate |
735 | * | 735 | * |
736 | * Called every time we receive a request from the client. | 736 | * Called every time we receive a request from the client. |
737 | */ | 737 | */ |
738 | void | 738 | void |
@@ -836,14 +836,14 @@ void client_respond (void *cls, | |||
836 | ids, | 836 | ids, |
837 | num_peers * sizeof (struct GNUNET_PeerIdentity)); | 837 | num_peers * sizeof (struct GNUNET_PeerIdentity)); |
838 | GNUNET_free (ids); | 838 | GNUNET_free (ids); |
839 | 839 | ||
840 | cli_ctx = GNUNET_SERVER_client_get_user_context (client, struct client_ctx); | 840 | cli_ctx = GNUNET_SERVER_client_get_user_context (client, struct client_ctx); |
841 | if ( NULL == cli_ctx ) { | 841 | if ( NULL == cli_ctx ) { |
842 | cli_ctx = GNUNET_new (struct client_ctx); | 842 | cli_ctx = GNUNET_new (struct client_ctx); |
843 | cli_ctx->mq = GNUNET_MQ_queue_for_server_client (client); | 843 | cli_ctx->mq = GNUNET_MQ_queue_for_server_client (client); |
844 | GNUNET_SERVER_client_set_user_context (client, cli_ctx); | 844 | GNUNET_SERVER_client_set_user_context (client, cli_ctx); |
845 | } | 845 | } |
846 | 846 | ||
847 | GNUNET_MQ_send (cli_ctx->mq, ev); | 847 | GNUNET_MQ_send (cli_ctx->mq, ev); |
848 | } | 848 | } |
849 | 849 | ||
@@ -950,12 +950,12 @@ handle_peer_push (void *cls, | |||
950 | { | 950 | { |
951 | const struct GNUNET_PeerIdentity *peer; | 951 | const struct GNUNET_PeerIdentity *peer; |
952 | 952 | ||
953 | // (check the proof of work) | 953 | // (check the proof of work) |
954 | 954 | ||
955 | peer = (const struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); | 955 | peer = (const struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); |
956 | // FIXME wait for cadet to change this function | 956 | // FIXME wait for cadet to change this function |
957 | LOG (GNUNET_ERROR_TYPE_DEBUG, "PUSH received (%s)\n", GNUNET_i2s (peer)); | 957 | LOG (GNUNET_ERROR_TYPE_DEBUG, "PUSH received (%s)\n", GNUNET_i2s (peer)); |
958 | 958 | ||
959 | /* Add the sending peer to the push_list */ | 959 | /* Add the sending peer to the push_list */ |
960 | if (GNUNET_NO == in_arr (push_list, pull_list_size, peer)) | 960 | if (GNUNET_NO == in_arr (push_list, pull_list_size, peer)) |
961 | GNUNET_array_append (push_list, push_list_size, *peer); | 961 | GNUNET_array_append (push_list, push_list_size, *peer); |
@@ -1140,7 +1140,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1140 | for ( i = 0 ; i < n_peers ; i++ ) | 1140 | for ( i = 0 ; i < n_peers ; i++ ) |
1141 | { | 1141 | { |
1142 | peer = &gossip_list[permut[i]]; | 1142 | peer = &gossip_list[permut[i]]; |
1143 | if (own_identity != peer) // TODO | 1143 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) // TODO |
1144 | { // FIXME if this fails schedule/loop this for later | 1144 | { // FIXME if this fails schedule/loop this for later |
1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
1146 | 1146 | ||
@@ -1170,7 +1170,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1170 | { | 1170 | { |
1171 | GNUNET_array_append (pending_pull_reply_list, pending_pull_reply_list_size, *peer); | 1171 | GNUNET_array_append (pending_pull_reply_list, pending_pull_reply_list_size, *peer); |
1172 | 1172 | ||
1173 | if (own_identity != peer) | 1173 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) |
1174 | { // FIXME if this fails schedule/loop this for later | 1174 | { // FIXME if this fails schedule/loop this for later |
1175 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 1175 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
1176 | 1176 | ||
@@ -1195,7 +1195,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1195 | 1195 | ||
1196 | uint32_t first_border; | 1196 | uint32_t first_border; |
1197 | uint32_t second_border; | 1197 | uint32_t second_border; |
1198 | 1198 | ||
1199 | first_border = round (alpha * sampler_size_est_need); | 1199 | first_border = round (alpha * sampler_size_est_need); |
1200 | second_border = first_border + round (beta * sampler_size_est_need); | 1200 | second_border = first_border + round (beta * sampler_size_est_need); |
1201 | 1201 | ||
@@ -1392,13 +1392,13 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | |||
1392 | 1392 | ||
1393 | if ( NULL != peer_ctx->send_channel) | 1393 | if ( NULL != peer_ctx->send_channel) |
1394 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | 1394 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); |
1395 | 1395 | ||
1396 | if ( NULL != peer_ctx->recv_channel) | 1396 | if ( NULL != peer_ctx->recv_channel) |
1397 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | 1397 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); |
1398 | 1398 | ||
1399 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) | 1399 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) |
1400 | LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); | 1400 | LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); |
1401 | 1401 | ||
1402 | return GNUNET_YES; | 1402 | return GNUNET_YES; |
1403 | } | 1403 | } |
1404 | 1404 | ||
@@ -1421,7 +1421,7 @@ shutdown_task (void *cls, | |||
1421 | do_round_task = NULL; | 1421 | do_round_task = NULL; |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | 1424 | ||
1425 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) | 1425 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) |
1426 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1426 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1427 | "Iterating over peers to disconnect from them was cancelled\n"); | 1427 | "Iterating over peers to disconnect from them was cancelled\n"); |
@@ -1430,7 +1430,6 @@ shutdown_task (void *cls, | |||
1430 | 1430 | ||
1431 | GNUNET_NSE_disconnect (nse); | 1431 | GNUNET_NSE_disconnect (nse); |
1432 | GNUNET_CADET_disconnect (cadet_handle); | 1432 | GNUNET_CADET_disconnect (cadet_handle); |
1433 | GNUNET_free (own_identity); | ||
1434 | RPS_sampler_destroy (); | 1433 | RPS_sampler_destroy (); |
1435 | GNUNET_array_grow (request_deltas, request_deltas_size, 0); | 1434 | GNUNET_array_grow (request_deltas, request_deltas_size, 0); |
1436 | GNUNET_array_grow (gossip_list, gossip_list_size, 0); | 1435 | GNUNET_array_grow (gossip_list, gossip_list_size, 0); |
@@ -1571,18 +1570,14 @@ run (void *cls, | |||
1571 | // TODO check what this does -- copied from gnunet-boss | 1570 | // TODO check what this does -- copied from gnunet-boss |
1572 | // - seems to work as expected | 1571 | // - seems to work as expected |
1573 | GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); | 1572 | GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); |
1574 | |||
1575 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS started\n"); | ||
1576 | |||
1577 | |||
1578 | cfg = c; | 1573 | cfg = c; |
1579 | 1574 | ||
1580 | 1575 | ||
1581 | /* Get own ID */ | 1576 | /* Get own ID */ |
1582 | own_identity = GNUNET_new (struct GNUNET_PeerIdentity); | 1577 | GNUNET_CRYPTO_get_peer_identity (cfg, &own_identity); // TODO check return value |
1583 | GNUNET_CRYPTO_get_peer_identity (cfg, own_identity); // TODO check return value | 1578 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1584 | GNUNET_assert (NULL != own_identity); | 1579 | "STARTING SERVICE (rps) for peer [%s]\n", |
1585 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Own identity is %s (at %p).\n", GNUNET_i2s (own_identity), own_identity); | 1580 | GNUNET_i2s (&own_identity)); |
1586 | 1581 | ||
1587 | 1582 | ||
1588 | /* Get time interval from the configuration */ | 1583 | /* Get time interval from the configuration */ |