aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2014-12-24 16:59:19 +0000
committerJulius Bünger <buenger@mytum.de>2014-12-24 16:59:19 +0000
commitd732e59ca621101f0d58a788214dbda7833bbc2a (patch)
treef6a53ce6c560ebb282c4db33a9e2903ece3ecc71 /src
parent471ed8e8d0f2d7246fc2ec217357dadb9be0817b (diff)
downloadgnunet-d732e59ca621101f0d58a788214dbda7833bbc2a.tar.gz
gnunet-d732e59ca621101f0d58a788214dbda7833bbc2a.zip
minor fixes
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_rps_service.h2
-rw-r--r--src/rps/gnunet-service-rps.c32
-rw-r--r--src/rps/test_rps.conf2
-rw-r--r--src/rps/test_rps_multipeer.c8
4 files changed, 11 insertions, 33 deletions
diff --git a/src/include/gnunet_rps_service.h b/src/include/gnunet_rps_service.h
index 2b0d136cb..497e9b67e 100644
--- a/src/include/gnunet_rps_service.h
+++ b/src/include/gnunet_rps_service.h
@@ -56,7 +56,7 @@ struct GNUNET_RPS_Request_Handle;
56 * @param num_peers the number of peers returned 56 * @param num_peers the number of peers returned
57 * @param peers array with num_peers PeerIDs 57 * @param peers array with num_peers PeerIDs
58 */ 58 */
59typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, struct GNUNET_PeerIdentity *peers); 59typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers);
60 60
61/** 61/**
62 * Request n random peers. 62 * Request n random peers.
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 1e7344117..a3bfbc536 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -774,7 +774,7 @@ touch_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNU
774 } 774 }
775 else 775 else
776 { 776 {
777 ctx = GNUNET_malloc(sizeof(struct peer_context)); 777 ctx = GNUNET_new(struct peer_context);
778 ctx->in_flags = 0; 778 ctx->in_flags = 0;
779 ctx->mq = NULL; 779 ctx->mq = NULL;
780 ctx->to_channel = NULL; 780 ctx->to_channel = NULL;
@@ -924,7 +924,6 @@ handle_cs_request (void *cls,
924 924
925 // TODO 925 // TODO
926 msg = (struct GNUNET_RPS_CS_RequestMessage *) message; 926 msg = (struct GNUNET_RPS_CS_RequestMessage *) message;
927 // Does not work because the compiler seems not to find it.
928 cli_ctx = GNUNET_SERVER_client_get_user_context(client, struct client_ctx); 927 cli_ctx = GNUNET_SERVER_client_get_user_context(client, struct client_ctx);
929 if ( NULL == cli_ctx ) { 928 if ( NULL == cli_ctx ) {
930 cli_ctx = GNUNET_new(struct client_ctx); 929 cli_ctx = GNUNET_new(struct client_ctx);
@@ -932,7 +931,7 @@ handle_cs_request (void *cls,
932 GNUNET_SERVER_client_set_user_context(client, cli_ctx); 931 GNUNET_SERVER_client_set_user_context(client, cli_ctx);
933 } 932 }
934 933
935 // TODO How many peers do we give back? 934 // How many peers do we give back?
936 // Wait until we have enough random peers? 935 // Wait until we have enough random peers?
937 936
938 ev = GNUNET_MQ_msg_extra(out_msg, 937 ev = GNUNET_MQ_msg_extra(out_msg,
@@ -975,9 +974,6 @@ handle_peer_push (void *cls,
975 struct GNUNET_PeerIdentity *peer; 974 struct GNUNET_PeerIdentity *peer;
976 975
977 // TODO check the proof of work 976 // TODO check the proof of work
978 // and check limit for PUSHes
979 // IF we count per peer PUSHes
980 // maybe remove from gossip/sampler list
981 977
982 peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info( channel, GNUNET_CADET_OPTION_PEER ); 978 peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info( channel, GNUNET_CADET_OPTION_PEER );
983 979
@@ -1012,15 +1008,15 @@ handle_peer_pull_request (void *cls,
1012 struct GNUNET_MQ_Envelope *ev; 1008 struct GNUNET_MQ_Envelope *ev;
1013 struct GNUNET_RPS_P2P_PullReplyMessage *out_msg; 1009 struct GNUNET_RPS_P2P_PullReplyMessage *out_msg;
1014 1010
1015 // TODO find some way to keep one peer from spamming with pull requests 1011 // find some way to keep one peer from spamming with pull requests?
1016 // allow only one request per time interval ? 1012 // allow only one request per time interval ?
1017 // otherwise remove from peerlist? 1013 // otherwise remove from peerlist?
1018 1014
1019 peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info(channel, GNUNET_CADET_OPTION_PEER); 1015 peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info(channel, GNUNET_CADET_OPTION_PEER);
1020 LOG(GNUNET_ERROR_TYPE_DEBUG, "PULL REQUEST from peer %s received\n", GNUNET_i2s(peer)); 1016 LOG(GNUNET_ERROR_TYPE_DEBUG, "PULL REQUEST from peer %s received\n", GNUNET_i2s(peer));
1021 1017
1022 mq = GNUNET_CADET_mq_create(channel); // TODO without mq? 1018 //mq = GNUNET_CADET_mq_create(channel); // without mq?
1023 //mq = get_mq(peer_map, peer); 1019 mq = get_mq(peer_map, peer);
1024 1020
1025 //in_msg = (struct GNUNET_RPS_P2P_PullRequestMessage *) msg; 1021 //in_msg = (struct GNUNET_RPS_P2P_PullRequestMessage *) msg;
1026 // TODO how many peers do we actually send? 1022 // TODO how many peers do we actually send?
@@ -1034,9 +1030,6 @@ handle_peer_pull_request (void *cls,
1034 1030
1035 GNUNET_MQ_send(mq, ev); 1031 GNUNET_MQ_send(mq, ev);
1036 1032
1037 GNUNET_MQ_destroy(mq);
1038
1039
1040 return GNUNET_OK; 1033 return GNUNET_OK;
1041} 1034}
1042 1035
@@ -1067,12 +1060,11 @@ handle_peer_pull_reply (void *cls,
1067 1060
1068 in_msg = (struct GNUNET_RPS_P2P_PullReplyMessage *) msg; 1061 in_msg = (struct GNUNET_RPS_P2P_PullReplyMessage *) msg;
1069 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 1062 peers = (struct GNUNET_PeerIdentity *) &msg[1];
1070 for ( i = 0 ; i < GNUNET_ntohll(in_msg->num_peers) ; i++ ) { 1063 for ( i = 0 ; i < GNUNET_ntohll(in_msg->num_peers) ; i++ )
1064 {
1071 GNUNET_array_append(pull_list, pull_list_size, peers[i]); 1065 GNUNET_array_append(pull_list, pull_list_size, peers[i]);
1072 } 1066 }
1073 1067
1074 // TODO maybe a disconnect happens here
1075
1076 return GNUNET_OK; 1068 return GNUNET_OK;
1077} 1069}
1078 1070
@@ -1232,7 +1224,8 @@ do_round(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1232 void 1224 void
1233insertCB (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_HashCode hash) 1225insertCB (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_HashCode hash)
1234{ 1226{
1235 touch_mq(peer_map, id); 1227 // We open a channel to be notified when this peer goes down.
1228 touch_channel(peer_map, id);
1236} 1229}
1237 1230
1238/** 1231/**
@@ -1298,8 +1291,6 @@ init_peer_cb (void *cls,
1298} 1291}
1299 1292
1300 1293
1301
1302
1303/** 1294/**
1304 * Task run during shutdown. 1295 * Task run during shutdown.
1305 * 1296 *
@@ -1321,13 +1312,10 @@ shutdown_task (void *cls,
1321 GNUNET_NSE_disconnect(nse); 1312 GNUNET_NSE_disconnect(nse);
1322 GNUNET_CADET_disconnect(cadet_handle); 1313 GNUNET_CADET_disconnect(cadet_handle);
1323 GNUNET_free(own_identity); 1314 GNUNET_free(own_identity);
1324 //GNUNET_free(round_interval);
1325 //GNUNET_free(gossip_list);
1326 SAMPLER_samplers_destroy(sampler_list); 1315 SAMPLER_samplers_destroy(sampler_list);
1327 GNUNET_array_grow(gossip_list, gossip_list_size, 0); 1316 GNUNET_array_grow(gossip_list, gossip_list_size, 0);
1328 GNUNET_array_grow(push_list, push_list_size, 0); 1317 GNUNET_array_grow(push_list, push_list_size, 0);
1329 GNUNET_array_grow(pull_list, pull_list_size, 0); 1318 GNUNET_array_grow(pull_list, pull_list_size, 0);
1330 // TODO delete global data
1331} 1319}
1332 1320
1333 1321
@@ -1421,7 +1409,6 @@ rps_start (struct GNUNET_SERVER_Handle *server)
1421 LOG(GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n"); 1409 LOG(GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n");
1422 1410
1423 1411
1424
1425 do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); 1412 do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
1426 LOG(GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); 1413 LOG(GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n");
1427 1414
@@ -1431,7 +1418,6 @@ rps_start (struct GNUNET_SERVER_Handle *server)
1431} 1418}
1432 1419
1433 1420
1434
1435/** 1421/**
1436 * Process statistics requests. 1422 * Process statistics requests.
1437 * 1423 *
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index ea683e96f..3fe601ede 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -1,6 +1,6 @@
1[rps] 1[rps]
2AUTOSTART = YES 2AUTOSTART = YES
3#PREFIX = valgrind --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p 3PREFIX = valgrind --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
4BINARY = gnunet-service-rps 4BINARY = gnunet-service-rps
5UNIXPATH = /tmp/gnunet-service-rps.sock 5UNIXPATH = /tmp/gnunet-service-rps.sock
6HOME = $SERVICEHOME 6HOME = $SERVICEHOME
diff --git a/src/rps/test_rps_multipeer.c b/src/rps/test_rps_multipeer.c
index 8941ecada..ccf4b7c72 100644
--- a/src/rps/test_rps_multipeer.c
+++ b/src/rps/test_rps_multipeer.c
@@ -96,14 +96,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
96static void 96static void
97handle_reply (void *cls, uint64_t n, struct GNUNET_PeerIdentity *peers) 97handle_reply (void *cls, uint64_t n, struct GNUNET_PeerIdentity *peers)
98{ 98{
99 //struct RPSPeer *peer = cls;
100
101 //FPRINTF (stderr,
102 // "Received network size estimate from peer %u. logSize: %f std.dev. %f (%f/%u)\n",
103 // (unsigned int) (peer - rps_peers),
104 // estimate, std_dev,
105 // GNUNET_NSE_log_estimate_to_n (estimate),
106 // NUM_PEERS);
107 99
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got peer %s\n", GNUNET_i2s(peers)); 100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got peer %s\n", GNUNET_i2s(peers));
109 101