gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (341c1dd69 -> 0bd93f589)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (341c1dd69 -> 0bd93f589)
Date: Mon, 13 Aug 2018 17:38:29 +0200

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from 341c1dd69 moved test files and fixed namestore
     new 8275d52ec Use synchronised logic for closing channels (rps service)
     new 0d0cf8738 Make non-exported functions static
     new be3250261 Refactor, simplify, delete code
     new 32a0ea5a3 Update po-files
     new 331809720 Schedule destruction of channel during destruction of other 
channel
     new 0bd93f589 Update po-files

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 po/POTFILES.in                         | 124 ++---
 src/cadet/Makefile.am                  |  12 +-
 src/cadet/test_cadet.c                 | 261 ++++++++---
 src/rps/gnunet-rps-profiler.c          |  20 +-
 src/rps/gnunet-service-rps.c           | 814 +++++++++++++--------------------
 src/rps/gnunet-service-rps_custommap.c |   1 +
 src/rps/rps-test_util.c                |   2 +-
 src/rps/test_rps.c                     |   2 +-
 src/rps/test_rps.conf                  |   1 +
 9 files changed, 610 insertions(+), 627 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1f2753b9b..5eda765b1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,21 +4,13 @@ src/arm/arm_monitor_api.c
 src/arm/gnunet-arm.c
 src/arm/gnunet-service-arm.c
 src/arm/mockup-service.c
-src/ats-tests/ats-testing-experiment.c
-src/ats-tests/ats-testing-log.c
-src/ats-tests/ats-testing-preferences.c
-src/ats-tests/ats-testing-traffic.c
-src/ats-tests/ats-testing.c
-src/ats-tests/gnunet-ats-sim.c
-src/ats-tests/gnunet-solver-eval.c
-src/ats-tool/gnunet-ats.c
 src/ats/ats_api_connectivity.c
 src/ats/ats_api_performance.c
 src/ats/ats_api_scanner.c
 src/ats/ats_api_scheduling.c
 src/ats/gnunet-ats-solver-eval.c
-src/ats/gnunet-service-ats.c
 src/ats/gnunet-service-ats_addresses.c
+src/ats/gnunet-service-ats.c
 src/ats/gnunet-service-ats_connectivity.c
 src/ats/gnunet-service-ats_normalization.c
 src/ats/gnunet-service-ats_performance.c
@@ -29,6 +21,14 @@ src/ats/gnunet-service-ats_scheduling.c
 src/ats/plugin_ats_mlp.c
 src/ats/plugin_ats_proportional.c
 src/ats/plugin_ats_ril.c
+src/ats-tests/ats-testing.c
+src/ats-tests/ats-testing-experiment.c
+src/ats-tests/ats-testing-log.c
+src/ats-tests/ats-testing-preferences.c
+src/ats-tests/ats-testing-traffic.c
+src/ats-tests/gnunet-ats-sim.c
+src/ats-tests/gnunet-solver-eval.c
+src/ats-tool/gnunet-ats.c
 src/auction/gnunet-auction-create.c
 src/auction/gnunet-auction-info.c
 src/auction/gnunet-auction-join.c
@@ -40,8 +40,8 @@ src/block/plugin_block_test.c
 src/cadet/cadet_api.c
 src/cadet/cadet_test_lib.c
 src/cadet/desirability_table.c
-src/cadet/gnunet-cadet-profiler.c
 src/cadet/gnunet-cadet.c
+src/cadet/gnunet-cadet-profiler.c
 src/cadet/gnunet-service-cadet.c
 src/cadet/gnunet-service-cadet_channel.c
 src/cadet/gnunet-service-cadet_connection.c
@@ -57,15 +57,15 @@ src/consensus/gnunet-service-consensus.c
 src/consensus/plugin_block_consensus.c
 src/conversation/conversation_api.c
 src/conversation/conversation_api_call.c
-src/conversation/gnunet-conversation-test.c
 src/conversation/gnunet-conversation.c
-src/conversation/gnunet-helper-audio-playback-gst.c
+src/conversation/gnunet-conversation-test.c
+src/conversation/gnunet_gst.c
+src/conversation/gnunet_gst_test.c
 src/conversation/gnunet-helper-audio-playback.c
-src/conversation/gnunet-helper-audio-record-gst.c
+src/conversation/gnunet-helper-audio-playback-gst.c
 src/conversation/gnunet-helper-audio-record.c
+src/conversation/gnunet-helper-audio-record-gst.c
 src/conversation/gnunet-service-conversation.c
-src/conversation/gnunet_gst.c
-src/conversation/gnunet_gst_test.c
 src/conversation/microphone.c
 src/conversation/plugin_gnsrecord_conversation.c
 src/conversation/speaker.c
@@ -102,6 +102,7 @@ src/dht/dht_api.c
 src/dht/dht_test_lib.c
 src/dht/gnunet-dht-get.c
 src/dht/gnunet-dht-monitor.c
+src/dht/gnunet_dht_profiler.c
 src/dht/gnunet-dht-put.c
 src/dht/gnunet-service-dht.c
 src/dht/gnunet-service-dht_clients.c
@@ -110,7 +111,6 @@ src/dht/gnunet-service-dht_hello.c
 src/dht/gnunet-service-dht_neighbours.c
 src/dht/gnunet-service-dht_nse.c
 src/dht/gnunet-service-dht_routing.c
-src/dht/gnunet_dht_profiler.c
 src/dht/plugin_block_dht.c
 src/dns/dns_api.c
 src/dns/gnunet-dns-monitor.c
@@ -124,8 +124,8 @@ src/dv/gnunet-dv.c
 src/dv/gnunet-service-dv.c
 src/dv/plugin_transport_dv.c
 src/exit/gnunet-daemon-exit.c
-src/exit/gnunet-helper-exit-windows.c
 src/exit/gnunet-helper-exit.c
+src/exit/gnunet-helper-exit-windows.c
 src/fragmentation/defragmentation.c
 src/fragmentation/fragmentation.c
 src/fs/fs_api.c
@@ -150,8 +150,8 @@ src/fs/gnunet-auto-share.c
 src/fs/gnunet-daemon-fsprofiler.c
 src/fs/gnunet-directory.c
 src/fs/gnunet-download.c
-src/fs/gnunet-fs-profiler.c
 src/fs/gnunet-fs.c
+src/fs/gnunet-fs-profiler.c
 src/fs/gnunet-helper-fs-publish.c
 src/fs/gnunet-publish.c
 src/fs/gnunet-search.c
@@ -171,10 +171,10 @@ src/gns/gns_tld_api.c
 src/gns/gnunet-bcd.c
 src/gns/gnunet-dns2gns.c
 src/gns/gnunet-gns-benchmark.c
+src/gns/gnunet-gns.c
 src/gns/gnunet-gns-helper-service-w32.c
 src/gns/gnunet-gns-import.c
 src/gns/gnunet-gns-proxy.c
-src/gns/gnunet-gns.c
 src/gns/gnunet-service-gns.c
 src/gns/gnunet-service-gns_interceptor.c
 src/gns/gnunet-service-gns_resolver.c
@@ -182,15 +182,16 @@ src/gns/nss/nss_gns.c
 src/gns/nss/nss_gns_query.c
 src/gns/plugin_block_gns.c
 src/gns/plugin_gnsrecord_gns.c
-src/gns/w32nsp-install.c
-src/gns/w32nsp-resolve.c
-src/gns/w32nsp-uninstall.c
-src/gns/w32nsp.c
+src/gns/plugin_rest_gns.c
 src/gnsrecord/gnsrecord.c
 src/gnsrecord/gnsrecord_crypto.c
 src/gnsrecord/gnsrecord_misc.c
 src/gnsrecord/gnsrecord_serialization.c
 src/gnsrecord/plugin_gnsrecord_dns.c
+src/gns/w32nsp.c
+src/gns/w32nsp-install.c
+src/gns/w32nsp-resolve.c
+src/gns/w32nsp-uninstall.c
 src/hello/address.c
 src/hello/gnunet-hello.c
 src/hello/hello.c
@@ -201,17 +202,17 @@ src/identity/gnunet-identity.c
 src/identity/gnunet-service-identity.c
 src/identity/identity_api.c
 src/identity/identity_api_lookup.c
-src/json/json.c
-src/json/json_generator.c
-src/json/json_gnsrecord.c
-src/json/json_helper.c
-src/json/json_mhd.c
+src/identity/plugin_rest_identity.c
 src/jsonapi/jsonapi.c
 src/jsonapi/jsonapi_document.c
 src/jsonapi/jsonapi_error.c
 src/jsonapi/jsonapi_relationship.c
 src/jsonapi/jsonapi_resource.c
-src/jsonapi/plugin_rest_reclaim.c
+src/json/json.c
+src/json/json_generator.c
+src/json/json_gnsrecord.c
+src/json/json_helper.c
+src/json/json_mhd.c
 src/multicast/gnunet-multicast.c
 src/multicast/gnunet-service-multicast.c
 src/multicast/multicast_api.c
@@ -225,8 +226,8 @@ src/namecache/namecache_api.c
 src/namecache/plugin_namecache_flat.c
 src/namecache/plugin_namecache_postgres.c
 src/namecache/plugin_namecache_sqlite.c
-src/namestore/gnunet-namestore-fcfsd.c
 src/namestore/gnunet-namestore.c
+src/namestore/gnunet-namestore-fcfsd.c
 src/namestore/gnunet-service-namestore.c
 src/namestore/gnunet-zoneimport.c
 src/namestore/namestore_api.c
@@ -241,10 +242,10 @@ src/nat-auto/gnunet-service-nat-auto.c
 src/nat-auto/gnunet-service-nat-auto_legacy.c
 src/nat-auto/nat_auto_api.c
 src/nat-auto/nat_auto_api_test.c
-src/nat/gnunet-helper-nat-client-windows.c
 src/nat/gnunet-helper-nat-client.c
-src/nat/gnunet-helper-nat-server-windows.c
+src/nat/gnunet-helper-nat-client-windows.c
 src/nat/gnunet-helper-nat-server.c
+src/nat/gnunet-helper-nat-server-windows.c
 src/nat/gnunet-nat.c
 src/nat/gnunet-service-nat.c
 src/nat/gnunet-service-nat_externalip.c
@@ -253,15 +254,15 @@ src/nat/gnunet-service-nat_mini.c
 src/nat/gnunet-service-nat_stun.c
 src/nat/nat_api.c
 src/nat/nat_api_stun.c
-src/nse/gnunet-nse-profiler.c
 src/nse/gnunet-nse.c
+src/nse/gnunet-nse-profiler.c
 src/nse/gnunet-service-nse.c
 src/nse/nse_api.c
-src/peerinfo-tool/gnunet-peerinfo.c
-src/peerinfo-tool/gnunet-peerinfo_plugins.c
 src/peerinfo/gnunet-service-peerinfo.c
 src/peerinfo/peerinfo_api.c
 src/peerinfo/peerinfo_api_notify.c
+src/peerinfo-tool/gnunet-peerinfo.c
+src/peerinfo-tool/gnunet-peerinfo_plugins.c
 src/peerstore/gnunet-peerstore.c
 src/peerstore/gnunet-service-peerstore.c
 src/peerstore/peerstore_api.c
@@ -291,6 +292,7 @@ src/reclaim-attribute/reclaim_attribute.c
 src/reclaim/gnunet-reclaim.c
 src/reclaim/gnunet-service-reclaim.c
 src/reclaim/jwt.c
+src/reclaim/oidc_helper.c
 src/reclaim/plugin_gnsrecord_reclaim.c
 src/reclaim/plugin_reclaim_sqlite.c
 src/reclaim/reclaim_api.c
@@ -316,25 +318,27 @@ src/rest-plugins/plugin_rest_namestore.c
 src/rest-plugins/plugin_rest_openid_connect.c
 src/rest-plugins/plugin_rest_peerinfo.c
 src/rest/gnunet-rest-server.c
+src/rest/plugin_rest_copying.c
 src/rest/rest.c
 src/revocation/gnunet-revocation.c
 src/revocation/gnunet-service-revocation.c
 src/revocation/plugin_block_revocation.c
 src/revocation/revocation_api.c
-src/rps/gnunet-rps-profiler.c
 src/rps/gnunet-rps.c
+src/rps/gnunet-rps-profiler.c
 src/rps/gnunet-service-rps.c
 src/rps/gnunet-service-rps_custommap.c
 src/rps/gnunet-service-rps_sampler.c
 src/rps/gnunet-service-rps_sampler_elem.c
 src/rps/gnunet-service-rps_view.c
-src/rps/rps-test_util.c
 src/rps/rps_api.c
+src/rps/rps_test_lib.c
+src/rps/rps-test_util.c
 src/scalarproduct/gnunet-scalarproduct.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
 src/scalarproduct/gnunet-service-scalarproduct_alice.c
 src/scalarproduct/gnunet-service-scalarproduct_bob.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
 src/scalarproduct/scalarproduct_api.c
 src/secretsharing/gnunet-secretsharing-profiler.c
 src/secretsharing/gnunet-service-secretsharing.c
@@ -363,16 +367,15 @@ src/statistics/gnunet-statistics.c
 src/statistics/statistics_api.c
 src/template/gnunet-service-template.c
 src/template/gnunet-template.c
-src/testbed-logger/gnunet-service-testbed-logger.c
-src/testbed-logger/testbed_logger_api.c
 src/testbed/generate-underlay-topology.c
 src/testbed/gnunet-daemon-latency-logger.c
 src/testbed/gnunet-daemon-testbed-blacklist.c
 src/testbed/gnunet-daemon-testbed-underlay.c
 src/testbed/gnunet-helper-testbed.c
+src/testbed/gnunet_mpi_test.c
 src/testbed/gnunet-service-test-barriers.c
-src/testbed/gnunet-service-testbed.c
 src/testbed/gnunet-service-testbed_barriers.c
+src/testbed/gnunet-service-testbed.c
 src/testbed/gnunet-service-testbed_cache.c
 src/testbed/gnunet-service-testbed_connectionpool.c
 src/testbed/gnunet-service-testbed_cpustatus.c
@@ -380,19 +383,20 @@ src/testbed/gnunet-service-testbed_links.c
 src/testbed/gnunet-service-testbed_meminfo.c
 src/testbed/gnunet-service-testbed_oc.c
 src/testbed/gnunet-service-testbed_peers.c
-src/testbed/gnunet-testbed-profiler.c
-src/testbed/gnunet_mpi_test.c
 src/testbed/gnunet_testbed_mpi_spawn.c
-src/testbed/testbed_api.c
+src/testbed/gnunet-testbed-profiler.c
+src/testbed-logger/gnunet-service-testbed-logger.c
+src/testbed-logger/testbed_logger_api.c
 src/testbed/testbed_api_barriers.c
+src/testbed/testbed_api.c
 src/testbed/testbed_api_hosts.c
 src/testbed/testbed_api_operations.c
 src/testbed/testbed_api_peers.c
 src/testbed/testbed_api_sd.c
 src/testbed/testbed_api_services.c
 src/testbed/testbed_api_statistics.c
-src/testbed/testbed_api_test.c
 src/testbed/testbed_api_testbed.c
+src/testbed/testbed_api_test.c
 src/testbed/testbed_api_topology.c
 src/testbed/testbed_api_underlay.c
 src/testing/gnunet-testing.c
@@ -401,28 +405,28 @@ src/testing/testing.c
 src/topology/friends.c
 src/topology/gnunet-daemon-topology.c
 src/transport/gnunet-helper-transport-bluetooth.c
-src/transport/gnunet-helper-transport-wlan-dummy.c
 src/transport/gnunet-helper-transport-wlan.c
-src/transport/gnunet-service-transport.c
+src/transport/gnunet-helper-transport-wlan-dummy.c
 src/transport/gnunet-service-transport_ats.c
+src/transport/gnunet-service-transport.c
 src/transport/gnunet-service-transport_hello.c
 src/transport/gnunet-service-transport_manipulation.c
 src/transport/gnunet-service-transport_neighbours.c
 src/transport/gnunet-service-transport_plugins.c
 src/transport/gnunet-service-transport_validation.c
+src/transport/gnunet-transport.c
 src/transport/gnunet-transport-certificate-creation.c
 src/transport/gnunet-transport-profiler.c
 src/transport/gnunet-transport-wlan-receiver.c
 src/transport/gnunet-transport-wlan-sender.c
-src/transport/gnunet-transport.c
 src/transport/plugin_transport_http_client.c
 src/transport/plugin_transport_http_common.c
 src/transport/plugin_transport_http_server.c
 src/transport/plugin_transport_smtp.c
 src/transport/plugin_transport_tcp.c
 src/transport/plugin_transport_template.c
-src/transport/plugin_transport_udp.c
 src/transport/plugin_transport_udp_broadcasting.c
+src/transport/plugin_transport_udp.c
 src/transport/plugin_transport_unix.c
 src/transport/plugin_transport_wlan.c
 src/transport/plugin_transport_xt.c
@@ -431,11 +435,6 @@ src/transport/tcp_connection_legacy.c
 src/transport/tcp_server_legacy.c
 src/transport/tcp_server_mst_legacy.c
 src/transport/tcp_service_legacy.c
-src/transport/transport-testing-filenames.c
-src/transport/transport-testing-loggers.c
-src/transport/transport-testing-main.c
-src/transport/transport-testing-send.c
-src/transport/transport-testing.c
 src/transport/transport_api_address_to_string.c
 src/transport/transport_api_blacklist.c
 src/transport/transport_api_core.c
@@ -444,6 +443,11 @@ src/transport/transport_api_manipulation.c
 src/transport/transport_api_monitor_peers.c
 src/transport/transport_api_monitor_plugins.c
 src/transport/transport_api_offer_hello.c
+src/transport/transport-testing.c
+src/transport/transport-testing-filenames.c
+src/transport/transport-testing-loggers.c
+src/transport/transport-testing-main.c
+src/transport/transport-testing-send.c
 src/util/bandwidth.c
 src/util/bio.c
 src/util/client.c
@@ -455,8 +459,8 @@ src/util/configuration_loader.c
 src/util/container_bloomfilter.c
 src/util/container_heap.c
 src/util/container_meta_data.c
-src/util/container_multihashmap.c
 src/util/container_multihashmap32.c
+src/util/container_multihashmap.c
 src/util/container_multipeermap.c
 src/util/container_multishortmap.c
 src/util/crypto_abe.c
@@ -478,15 +482,15 @@ src/util/dnsparser.c
 src/util/dnsstub.c
 src/util/getopt.c
 src/util/getopt_helpers.c
-src/util/gnunet-config-diff.c
 src/util/gnunet-config.c
+src/util/gnunet-config-diff.c
 src/util/gnunet-ecc.c
 src/util/gnunet-helper-w32-console.c
 src/util/gnunet-resolver.c
 src/util/gnunet-scrypt.c
 src/util/gnunet-service-resolver.c
-src/util/gnunet-timeout-w32.c
 src/util/gnunet-timeout.c
+src/util/gnunet-timeout-w32.c
 src/util/gnunet-uri.c
 src/util/helper.c
 src/util/load.c
@@ -514,13 +518,13 @@ src/util/tun.c
 src/util/w32cat.c
 src/util/win.c
 src/util/winproc.c
-src/vpn/gnunet-helper-vpn-windows.c
 src/vpn/gnunet-helper-vpn.c
+src/vpn/gnunet-helper-vpn-windows.c
 src/vpn/gnunet-service-vpn.c
 src/vpn/gnunet-vpn.c
 src/vpn/vpn_api.c
-src/zonemaster/gnunet-service-zonemaster-monitor.c
 src/zonemaster/gnunet-service-zonemaster.c
+src/zonemaster/gnunet-service-zonemaster-monitor.c
 src/fs/fs_api.h
 src/include/gnunet_common.h
 src/include/gnunet_mq_lib.h
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am
index ce30ebe46..b2d436061 100644
--- a/src/cadet/Makefile.am
+++ b/src/cadet/Makefile.am
@@ -90,6 +90,7 @@ check_PROGRAMS = \
   test_cadet_2_speed_backwards \
   test_cadet_2_speed_reliable \
   test_cadet_2_speed_reliable_backwards \
+  test_cadet_2_reopen \
   test_cadet_5_forward \
   test_cadet_5_signal \
   test_cadet_5_keepalive \
@@ -97,7 +98,8 @@ check_PROGRAMS = \
   test_cadet_5_speed_ack \
   test_cadet_5_speed_reliable \
   test_cadet_5_speed_reliable_backwards \
-  test_cadet_5_speed_backwards
+  test_cadet_5_speed_backwards \
+  test_cadet_5_reopen
 endif
 
 
@@ -197,6 +199,14 @@ test_cadet_5_speed_reliable_backwards_SOURCES = \
   test_cadet.c
 test_cadet_5_speed_reliable_backwards_LDADD = $(ld_cadet_test_lib)
 
+test_cadet_2_reopen_SOURCES = \
+  test_cadet.c
+test_cadet_2_reopen_LDADD = $(ld_cadet_test_lib)
+
+test_cadet_5_reopen_SOURCES = \
+  test_cadet.c
+test_cadet_5_reopen_LDADD = $(ld_cadet_test_lib)
+
 
 if ENABLE_TEST_RUN
 AM_TESTS_ENVIRONMENT=export 
GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};export 
PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH;unset XDG_DATA_HOME;unset 
XDG_CONFIG_HOME;
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index 5187bc504..76ff258e0 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -70,6 +70,7 @@ struct CadetTestChannelWrapper
 #define SPEED_ACK 4
 #define SPEED_REL 8
 #define P2P_SIGNAL 10
+#define REOPEN 11
 
 /**
  * Which test are we running?
@@ -177,6 +178,11 @@ struct GNUNET_CADET_TEST_Context *test_ctx;
 static struct GNUNET_SCHEDULER_Task *disconnect_task;
 
 /**
+ * Task called to reconnect peers.
+ */
+static struct GNUNET_SCHEDULER_Task *reconnect_task;
+
+/**
  * Task To perform tests
  */
 static struct GNUNET_SCHEDULER_Task *test_task;
@@ -374,7 +380,8 @@ stats_cont (void *cls,
              "KA sent: %u, KA received: %u\n",
               ka_sent,
              ka_received);
-  if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
+  if ((KEEPALIVE == test || REOPEN == test) &&
+      ((ka_sent < 2) || (ka_sent > ka_received + 1)))
   {
     GNUNET_break (0);
     ok--;
@@ -459,6 +466,152 @@ gather_stats_and_exit (void *cls)
 
 
 /**
+ * Send a message on the channel with the appropriate size and payload.
+ *
+ * Update the appropriate *_sent counter.
+ *
+ * @param channel Channel to send the message on.
+ */
+static void
+send_test_message (struct GNUNET_CADET_Channel *channel);
+
+/**
+ * Check if payload is sane (size contains payload).
+ *
+ * @param cls should match #ch
+ * @param message The actual message.
+ * @return #GNUNET_OK to keep the channel open,
+ *         #GNUNET_SYSERR to close it (signal serious error).
+ */
+static int
+check_data (void *cls,
+            const struct GNUNET_MessageHeader *message);
+
+/**
+ * Function is called whenever a message is received.
+ *
+ * @param cls closure (set from GNUNET_CADET_connect(), peer number)
+ * @param message the actual message
+ */
+static void
+handle_data (void *cls,
+             const struct GNUNET_MessageHeader *message);
+
+/**
+ * Function called whenever an MQ-channel is destroyed, even if the destruction
+ * was requested by #GNUNET_CADET_channel_destroy.
+ * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
+ *
+ * It should clean up any associated state, including cancelling any pending
+ * transmission on this channel.
+ *
+ * @param cls Channel closure (channel wrapper).
+ * @param channel Connection to the other end (henceforth invalid).
+ */
+static void
+disconnect_handler (void *cls,
+                     const struct GNUNET_CADET_Channel *channel);
+
+
+/**
+ * Task to reconnect to other peer.
+ *
+ * @param cls Closure (line from which the task was scheduled).
+ */
+static void
+reconnect_op (void *cls)
+{
+  struct GNUNET_MQ_MessageHandler handlers[] = {
+    GNUNET_MQ_hd_var_size (data,
+                           GNUNET_MESSAGE_TYPE_DUMMY,
+                           struct GNUNET_MessageHeader,
+                           NULL),
+    GNUNET_MQ_handler_end ()
+  };
+  long l = (long) cls;
+  struct CadetTestChannelWrapper *ch;
+  enum GNUNET_CADET_ChannelOption flags;
+
+  reconnect_task = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "reconnecting from line %ld\n",
+              l);
+  if (NULL != outgoing_ch)
+  {
+    GNUNET_CADET_channel_destroy (outgoing_ch);
+    outgoing_ch = NULL;
+  }
+  flags = GNUNET_CADET_OPTION_DEFAULT;
+  ch = GNUNET_new (struct CadetTestChannelWrapper);
+  outgoing_ch = GNUNET_CADET_channel_create (h1,
+                                             ch,
+                                             p_id[1],
+                                             &port,
+                                             flags,
+                                             NULL,
+                                             &disconnect_handler,
+                                             handlers);
+  ch->ch = outgoing_ch;
+  send_test_message (outgoing_ch);
+}
+
+/**
+ * Function called whenever an MQ-channel is destroyed, even if the destruction
+ * was requested by #GNUNET_CADET_channel_destroy.
+ * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
+ *
+ * It should clean up any associated state, including cancelling any pending
+ * transmission on this channel.
+ *
+ * @param cls Channel closure (channel wrapper).
+ * @param channel Connection to the other end (henceforth invalid).
+ */
+static void
+disconnect_handler (void *cls,
+                     const struct GNUNET_CADET_Channel *channel)
+{
+  struct CadetTestChannelWrapper *ch_w = cls;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Channel disconnected at %d\n",
+              ok);
+  GNUNET_assert (ch_w->ch == channel);
+  if (channel == incoming_ch)
+  {
+    ok++;
+    incoming_ch = NULL;
+  }
+  else if (outgoing_ch == channel)
+  {
+    if (P2P_SIGNAL == test)
+    {
+      ok++;
+    }
+    outgoing_ch = NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Unknown channel! %p\n",
+                channel);
+  if (NULL != disconnect_task && REOPEN != test)
+  {
+    GNUNET_SCHEDULER_cancel (disconnect_task);
+    disconnect_task =
+        GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
+                                  (void *) __LINE__);
+  }
+  else if (NULL != reconnect_task && REOPEN == test)
+  {
+    GNUNET_SCHEDULER_cancel (reconnect_task);
+    reconnect_task =
+        GNUNET_SCHEDULER_add_now (&reconnect_op,
+                                  (void *) __LINE__);
+  }
+  GNUNET_free (ch_w);
+}
+
+
+/**
  * Abort test: schedule disconnect and shutdown immediately
  *
  * @param line Line in the code the abort is requested from (__LINE__).
@@ -536,6 +689,14 @@ send_test_message (struct GNUNET_CADET_Channel *channel)
   {
     payload = data_sent;
   }
+  else if (REOPEN == test)
+  {
+    payload = data_sent;
+    data_sent++;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending DATA %u [%d bytes]\n",
+                data_sent, size);
+  }
   else
   {
     GNUNET_assert (0);
@@ -784,13 +945,29 @@ connect_handler (void *cls,
                 (long) cls);
     GNUNET_assert (0);
   }
-  if (NULL != disconnect_task)
+  if (NULL != disconnect_task && REOPEN != test)
   {
     GNUNET_SCHEDULER_cancel (disconnect_task);
     disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
                                                     &gather_stats_and_exit,
                                                     (void *) __LINE__);
   }
+  else if ((NULL != disconnect_task) && (REOPEN == test))
+  {
+    GNUNET_SCHEDULER_cancel (disconnect_task);
+    disconnect_task = GNUNET_SCHEDULER_add_delayed (
+        GNUNET_TIME_relative_multiply (short_time, 2),
+        &gather_stats_and_exit,
+        (void *) __LINE__);
+  }
+
+  if ((NULL != reconnect_task) && (REOPEN == test))
+  {
+    GNUNET_SCHEDULER_cancel (reconnect_task);
+    reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
+                                                   &reconnect_op,
+                                                   (void *) __LINE__);
+  }
 
   /* TODO: cannot return channel as-is, in order to unify the data handlers */
   ch = GNUNET_new (struct CadetTestChannelWrapper);
@@ -801,55 +978,6 @@ connect_handler (void *cls,
 
 
 /**
- * Function called whenever an MQ-channel is destroyed, even if the destruction
- * was requested by #GNUNET_CADET_channel_destroy.
- * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
- *
- * It should clean up any associated state, including cancelling any pending
- * transmission on this channel.
- *
- * @param cls Channel closure (channel wrapper).
- * @param channel Connection to the other end (henceforth invalid).
- */
-static void
-disconnect_handler (void *cls,
-                   const struct GNUNET_CADET_Channel *channel)
-{
-  struct CadetTestChannelWrapper *ch_w = cls;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             "Channel disconnected at %d\n",
-             ok);
-  GNUNET_assert (ch_w->ch == channel);
-  if (channel == incoming_ch)
-  {
-    ok++;
-    incoming_ch = NULL;
-  }
-  else if (outgoing_ch == channel)
-  {
-    if (P2P_SIGNAL == test)
-    {
-      ok++;
-    }
-    outgoing_ch = NULL;
-  }
-  else
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               "Unknown channel! %p\n",
-               channel);
-  if (NULL != disconnect_task)
-  {
-    GNUNET_SCHEDULER_cancel (disconnect_task);
-    disconnect_task =
-        GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
-                                 (void *) __LINE__);
-  }
-  GNUNET_free (ch_w);
-}
-
-
-/**
  * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
  *
  * Testcase continues when the root receives confirmation of connected peers,
@@ -871,7 +999,7 @@ start_test (void *cls)
   enum GNUNET_CADET_ChannelOption flags;
 
   test_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name);
   if (NULL != disconnect_task)
   {
     GNUNET_SCHEDULER_cancel (disconnect_task);
@@ -903,7 +1031,6 @@ start_test (void *cls)
   if (KEEPALIVE == test)
     return;                     /* Don't send any data. */
 
-
   data_received = 0;
   data_sent = 0;
   ack_received = 0;
@@ -912,6 +1039,18 @@ start_test (void *cls)
               "Sending data initializer on channel %p...\n",
               outgoing_ch);
   send_test_message (outgoing_ch);
+  if (REOPEN == test)
+  {
+    reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
+                                                   &reconnect_op,
+                                                   (void *) __LINE__);
+    GNUNET_SCHEDULER_cancel (disconnect_task);
+    disconnect_task = GNUNET_SCHEDULER_add_delayed (
+        GNUNET_TIME_relative_multiply (short_time, 2),
+        &gather_stats_and_exit,
+        (void *) __LINE__);
+  }
+
 }
 
 
@@ -1055,6 +1194,11 @@ main (int argc, char *argv[])
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
     peers_requested = 5;
   }
+  else if (strstr (argv[0], "_6_") != NULL)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "6 PEER LINE\n");
+    peers_requested = 6;
+  }
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
@@ -1122,6 +1266,17 @@ main (int argc, char *argv[])
      */
     ok_goal = 2;
   }
+  else if (strstr (argv[0], "_reopen") != NULL)
+  {
+    test = REOPEN;
+    test_name = "reopen";
+    ///* Test is supposed to generate the following callbacks:
+    // * 1 incoming channel (@dest)
+    // * [wait]
+    // * 1 received channel destroy (@dest)
+    // */
+    ok_goal = 7;
+  }
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 49714872f..277688b56 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -2311,14 +2311,14 @@ void write_final_stats (void){
 
   for (uint32_t i = 0; i < num_peers; i++)
   {
-    to_file ("/tmp/rps/final_stats.dat",
-             "%" PRIu32 " " /* index */
-             "%s %" /* id */
-             PRIu64 " %" /* rounds */
-             PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" 
PRIu64 " %" /* blocking */
-             PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
-             PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
-             PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
+    to_file ("/tmp/rps/final_stats.csv",
+             ", %" PRIu32 ", " /* index */
+             "%s, %" /* id */
+             PRIu64 ", %" /* rounds */
+             PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" 
PRIu64 ", %" /* blocking */
+             PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */
+             PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
+             PRIu64 ", %" PRIu64 ", %" PRIu64 /* recv */,
              i,
              GNUNET_i2s (rps_peers[i].peer_id),
              rps_peers[i].stats[STAT_TYPE_ROUNDS],
@@ -2407,10 +2407,10 @@ post_test_shutdown_ready_cb (void *cls,
     GNUNET_TESTBED_operation_done (rps_peer->stat_op);
   }
 
-  write_final_stats ();
+  //write_final_stats ();
   if (GNUNET_YES == check_statistics_collect_completed())
   {
-    //write_final_stats ();
+    write_final_stats ();
     GNUNET_free (stat_cls);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
         "Shutting down\n");
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 6b0ecc58c..e0301af6b 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -84,7 +84,7 @@ static struct GNUNET_HashCode port;
 /**
  * Set a peer flag of given peer context.
  */
-#define set_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
+#define SET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
 
 /**
  * Get peer flag of given peer context.
@@ -95,7 +95,7 @@ static struct GNUNET_HashCode port;
 /**
  * Unset flag of given peer context.
  */
-#define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
+#define UNSET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
 
 /**
  * Get channel flag of given channel context.
@@ -233,11 +233,6 @@ struct PeerContext
   struct PendingMessage *pending_messages_tail;
 
   /**
-   * @brief Task to destroy this context.
-   */
-  struct GNUNET_SCHEDULER_Task *destruction_task;
-
-  /**
    * This is pobably followed by 'statistical' data (when we first saw
    * it, how did we get its ID, how many pushes (in a timeinterval),
    * ...)
@@ -282,7 +277,9 @@ struct ChannelCtx
   struct PeerContext *peer_ctx;
 
   /**
-   * @brief Scheduled task that will destroy this context
+   * @brief When channel destruction needs to be delayed (because it is called
+   * from within the cadet routine of another channel destruction) this task
+   * refers to the respective _SCHEDULER_Task.
    */
   struct GNUNET_SCHEDULER_Task *destruction_task;
 };
@@ -314,7 +311,6 @@ static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
 static struct GNUNET_CADET_Handle *cadet_handle;
 
 
-
 /**
  * @brief Get the #PeerContext associated with a peer
  *
@@ -335,8 +331,28 @@ get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
   return ctx;
 }
 
-int
-Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer);
+/**
+ * @brief Check whether we have information about the given peer.
+ *
+ * FIXME probably deprecated. Make this the new _online.
+ *
+ * @param peer peer in question
+ *
+ * @return #GNUNET_YES if peer is known
+ *         #GNUNET_NO  if peer is not knwon
+ */
+static int
+check_peer_known (const struct GNUNET_PeerIdentity *peer)
+{
+  if (NULL != peer_map)
+  {
+    return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
+  } else
+  {
+    return GNUNET_NO;
+  }
+}
+
 
 /**
  * @brief Create a new #PeerContext and insert it into the peer map
@@ -351,7 +367,7 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
   struct PeerContext *ctx;
   int ret;
 
-  GNUNET_assert (GNUNET_NO == Peers_check_peer_known (peer));
+  GNUNET_assert (GNUNET_NO == check_peer_known (peer));
 
   ctx = GNUNET_new (struct PeerContext);
   ctx->peer_id = *peer;
@@ -372,18 +388,13 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
 static struct PeerContext *
 create_or_get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
 {
-  if (GNUNET_NO == Peers_check_peer_known (peer))
+  if (GNUNET_NO == check_peer_known (peer))
   {
     return create_peer_ctx (peer);
   }
   return get_peer_ctx (peer);
 }
 
-void
-Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags);
-
-void
-Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags);
 
 /**
  * @brief Check whether we have a connection to this @a peer
@@ -395,13 +406,13 @@ Peers_set_peer_flag (const struct GNUNET_PeerIdentity 
*peer, enum Peers_PeerFlag
  * @return #GNUNET_YES if we are connected
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_check_connected (const struct GNUNET_PeerIdentity *peer)
+static int
+check_connected (const struct GNUNET_PeerIdentity *peer)
 {
-  const struct PeerContext *peer_ctx;
+  struct PeerContext *peer_ctx;
 
   /* If we don't know about this peer we don't know whether it's online */
-  if (GNUNET_NO == Peers_check_peer_known (peer))
+  if (GNUNET_NO == check_peer_known (peer))
   {
     return GNUNET_NO;
   }
@@ -411,11 +422,11 @@ Peers_check_connected (const struct GNUNET_PeerIdentity 
*peer)
   if ( (NULL == peer_ctx->send_channel_ctx) &&
        (NULL == peer_ctx->recv_channel_ctx) )
   {
-    Peers_unset_peer_flag (peer, Peers_ONLINE);
+    UNSET_PEER_FLAG (peer_ctx, Peers_ONLINE);
     return GNUNET_NO;
   }
   /* Otherwise (if we have a channel, we know that it's online */
-  Peers_set_peer_flag (peer, Peers_ONLINE);
+  SET_PEER_FLAG (peer_ctx, Peers_ONLINE);
   return GNUNET_YES;
 }
 
@@ -559,7 +570,7 @@ set_peer_live (struct PeerContext *peer_ctx)
   }
 
   (void) add_valid_peer (peer);
-  set_peer_flag (peer_ctx, Peers_ONLINE);
+  SET_PEER_FLAG (peer_ctx, Peers_ONLINE);
 
   /* Call pending operations */
   for (i = 0; i < peer_ctx->num_pending_ops; i++)
@@ -604,7 +615,14 @@ handle_peer_pull_reply (void *cls,
  * @return The channel context
  */
 static struct ChannelCtx *
-add_channel_ctx (struct PeerContext *peer_ctx);
+add_channel_ctx (struct PeerContext *peer_ctx)
+{
+  struct ChannelCtx *channel_ctx;
+  channel_ctx = GNUNET_new (struct ChannelCtx);
+  channel_ctx->peer_ctx = peer_ctx;
+  return channel_ctx;
+}
+
 
 /**
  * @brief Remove the channel context from the DLL and free the memory.
@@ -612,7 +630,26 @@ add_channel_ctx (struct PeerContext *peer_ctx);
  * @param channel_ctx The channel context.
  */
 static void
-remove_channel_ctx (struct ChannelCtx *channel_ctx);
+remove_channel_ctx (struct ChannelCtx *channel_ctx)
+{
+  struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
+
+  if (channel_ctx == peer_ctx->send_channel_ctx)
+  {
+    GNUNET_free (channel_ctx);
+    peer_ctx->send_channel_ctx = NULL;
+    peer_ctx->mq = NULL;
+  }
+  else if (channel_ctx == peer_ctx->recv_channel_ctx)
+  {
+    GNUNET_free (channel_ctx);
+    peer_ctx->recv_channel_ctx = NULL;
+  }
+  else
+  {
+    GNUNET_assert (0);
+  }
+}
 
 
 /**
@@ -823,8 +860,143 @@ check_operation_scheduled (const struct 
GNUNET_PeerIdentity *peer,
   return GNUNET_NO;
 }
 
+/**
+ * @brief Callback for scheduler to destroy a channel
+ *
+ * @param cls Context of the channel
+ */
+static void
+destroy_channel (struct ChannelCtx *channel_ctx)
+{
+  struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
+
+  if (NULL != channel_ctx->destruction_task)
+  {
+    GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
+    channel_ctx->destruction_task = NULL;
+  }
+  GNUNET_CADET_channel_destroy (channel_ctx->channel);
+  channel_ctx->channel = NULL;
+  remove_channel_ctx (channel_ctx);
+}
+
+/**
+ * @brief Destroy a cadet channel.
+ *
+ * This satisfies the function signature of #GNUNET_SCHEDULER_TaskCallback.
+ *
+ * @param cls
+ */
+static void
+destroy_channel_cb (void *cls)
+{
+  struct ChannelCtx *channel_ctx = cls;
+  channel_ctx->destruction_task = NULL;
+  destroy_channel (channel_ctx);
+}
+
+/**
+ * @brief Schedule the destruction of a channel for immediately afterwards.
+ *
+ * In case a channel is to be destroyed from within the callback to the
+ * destruction of another channel (send channel), we cannot call
+ * GNUNET_CADET_channel_destroy directly, but need to use this scheduling
+ * construction.
+ *
+ * @param channel_ctx channel to be destroyed.
+ */
+static void
+schedule_channel_destruction (struct ChannelCtx *channel_ctx)
+{
+  channel_ctx->destruction_task =
+    GNUNET_SCHEDULER_add_now (destroy_channel_cb, channel_ctx);
+}
+
+/**
+ * @brief Remove peer
+ *
+ * @param peer the peer to clean
+ * @return #GNUNET_YES if peer was removed
+ *         #GNUNET_NO  otherwise
+ */
 static int
-Peers_remove_peer (const struct GNUNET_PeerIdentity *peer);
+destroy_peer (struct PeerContext *peer_ctx)
+{
+  GNUNET_assert (NULL != peer_ctx);
+  GNUNET_assert (NULL != peer_map);
+  if (GNUNET_NO ==
+      GNUNET_CONTAINER_multipeermap_contains (peer_map,
+                                              &peer_ctx->peer_id))
+  {
+    return GNUNET_NO;
+  }
+  SET_PEER_FLAG (peer_ctx, Peers_TO_DESTROY);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Going to remove peer %s\n",
+       GNUNET_i2s (&peer_ctx->peer_id));
+  UNSET_PEER_FLAG (peer_ctx, Peers_ONLINE);
+
+  /* Clear list of pending operations */
+  // TODO this probably leaks memory
+  //      ('only' the cls to the function. Not sure what to do with it)
+  GNUNET_array_grow (peer_ctx->pending_ops,
+                     peer_ctx->num_pending_ops,
+                     0);
+  /* Remove all pending messages */
+  while (NULL != peer_ctx->pending_messages_head)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Removing unsent %s\n",
+         peer_ctx->pending_messages_head->type);
+    /* Cancle pending message, too */
+    if ( (NULL != peer_ctx->liveliness_check_pending) &&
+         (0 == memcmp (peer_ctx->pending_messages_head,
+                     peer_ctx->liveliness_check_pending,
+                     sizeof (struct PendingMessage))) )
+      {
+        // TODO this may leak memory
+        peer_ctx->liveliness_check_pending = NULL;
+      }
+    remove_pending_message (peer_ctx->pending_messages_head,
+                            GNUNET_YES);
+  }
+
+  /* If we are still waiting for notification whether this peer is live
+   * cancel the according task */
+  if (NULL != peer_ctx->liveliness_check_pending)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Removing pending liveliness check for peer %s\n",
+                GNUNET_i2s (&peer_ctx->peer_id));
+    // TODO wait until cadet sets mq->cancel_impl
+    //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
+    remove_pending_message (peer_ctx->liveliness_check_pending,
+                            GNUNET_YES);
+    peer_ctx->liveliness_check_pending = NULL;
+  }
+
+  if (NULL != peer_ctx->send_channel_ctx)
+  {
+    /* This is possibly called from within channel destruction */
+    schedule_channel_destruction (peer_ctx->send_channel_ctx);
+  }
+  if (NULL != peer_ctx->recv_channel_ctx)
+  {
+    /* This is possibly called from within channel destruction */
+    schedule_channel_destruction (peer_ctx->recv_channel_ctx);
+  }
+
+  if (GNUNET_YES !=
+      GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
+                                                &peer_ctx->peer_id))
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "removing peer from peer_map failed\n");
+  }
+  GNUNET_free (peer_ctx);
+  return GNUNET_YES;
+}
+
 
 /**
  * Iterator over hash map entries. Deletes all contexts of peers.
@@ -840,7 +1012,7 @@ peermap_clear_iterator (void *cls,
                         const struct GNUNET_PeerIdentity *key,
                         void *value)
 {
-  Peers_remove_peer (key);
+  destroy_peer (get_peer_ctx (key));
   return GNUNET_YES;
 }
 
@@ -1084,8 +1256,8 @@ restore_valid_peers ()
  * @param cadet_h cadet handle
  * @param own_id own peer identity
  */
-void
-Peers_initialise (char* fn_valid_peers,
+static void
+initialise_peers (char* fn_valid_peers,
                   struct GNUNET_CADET_Handle *cadet_h)
 {
   filename_valid_peers = GNUNET_strdup (fn_valid_peers);
@@ -1097,7 +1269,7 @@ Peers_initialise (char* fn_valid_peers,
 
 
 /**
- * @brief Delete storage of peers that was created with #Peers_initialise ()
+ * @brief Delete storage of peers that was created with #initialise_peers ()
  */
 static void
 peers_terminate ()
@@ -1150,9 +1322,9 @@ valid_peer_iterator (void *cls,
  * @return the number of key value pairs processed,
  *         #GNUNET_SYSERR if it aborted iteration
  */
-int
-Peers_get_valid_peers (PeersIterator iterator,
-                       void *it_cls)
+static int
+get_valid_peers (PeersIterator iterator,
+                 void *it_cls)
 {
   struct PeersIteratorCls *cls;
   int ret;
@@ -1179,10 +1351,10 @@ Peers_get_valid_peers (PeersIterator iterator,
  * @return #GNUNET_YES if peer was inserted
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_insert_peer (const struct GNUNET_PeerIdentity *peer)
+static int
+insert_peer (const struct GNUNET_PeerIdentity *peer)
 {
-  if (GNUNET_YES == Peers_check_peer_known (peer))
+  if (GNUNET_YES == check_peer_known (peer))
   {
     return GNUNET_NO; /* We already know this peer - nothing to do */
   }
@@ -1190,8 +1362,30 @@ Peers_insert_peer (const struct GNUNET_PeerIdentity 
*peer)
   return GNUNET_YES;
 }
 
-int
-Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags);
+
+/**
+ * @brief Check whether flags on a peer are set.
+ *
+ * @param peer the peer to check the flag of
+ * @param flags the flags to check
+ *
+ * @return #GNUNET_SYSERR if peer is not known
+ *         #GNUNET_YES    if all given flags are set
+ *         #GNUNET_NO     otherwise
+ */
+static int
+check_peer_flag (const struct GNUNET_PeerIdentity *peer,
+                 enum Peers_PeerFlags flags)
+{
+  struct PeerContext *peer_ctx;
+
+  if (GNUNET_NO == check_peer_known (peer))
+  {
+    return GNUNET_SYSERR;
+  }
+  peer_ctx = get_peer_ctx (peer);
+  return check_peer_flag_set (peer_ctx, flags);
+}
 
 /**
  * @brief Try connecting to a peer to see whether it is online
@@ -1202,15 +1396,15 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity 
*peer, enum Peers_PeerFl
  * @return #GNUNET_YES if peer had to be inserted
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
+static int
+issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
   int ret;
 
-  ret = Peers_insert_peer (peer);
+  ret = insert_peer (peer);
   peer_ctx = get_peer_ctx (peer);
-  if ( (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) &&
+  if ( (GNUNET_NO == check_peer_flag (peer, Peers_ONLINE)) &&
        (NULL == peer_ctx->liveliness_check_pending) )
   {
     check_peer_live (peer_ctx);
@@ -1232,8 +1426,8 @@ Peers_issue_peer_liveliness_check (const struct 
GNUNET_PeerIdentity *peer)
  *         #GNUNET_NO     if peer is NOT removable
  *         #GNUNET_SYSERR if peer is not known
  */
-int
-Peers_check_removable (const struct GNUNET_PeerIdentity *peer)
+static int
+check_removable (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
@@ -1252,262 +1446,6 @@ Peers_check_removable (const struct GNUNET_PeerIdentity 
*peer)
   return GNUNET_YES;
 }
 
-uint32_t *
-Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer,
-                        enum Peers_ChannelRole role);
-
-int
-Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags 
flags);
-
-/**
- * @brief Callback for the scheduler to destroy the knowledge of a peer.
- *
- * @param cls Context of the peer
- */
-static void
-destroy_peer (void *cls)
-{
-  struct PeerContext *peer_ctx = cls;
-
-  GNUNET_assert (NULL != peer_ctx);
-  peer_ctx->destruction_task = NULL;
-  Peers_remove_peer (&peer_ctx->peer_id);
-}
-
-
-static void
-destroy_channel (void *cls);
-
-
-/**
- * @brief Schedule the destruction of the given channel.
- *
- * Do so only if it was not already scheduled and not during shutdown.
- *
- * @param channel_ctx The context of the channel to destroy.
- */
-static void
-schedule_channel_destruction (struct ChannelCtx *channel_ctx)
-{
-  GNUNET_assert (NULL != channel_ctx);
-  if (NULL != channel_ctx->destruction_task &&
-      GNUNET_NO == in_shutdown)
-  {
-    channel_ctx->destruction_task =
-      GNUNET_SCHEDULER_add_now (&destroy_channel,
-                               channel_ctx);
-  }
-}
-
-
-/**
- * @brief Schedule the destruction of the given peer.
- *
- * Do so only if it was not already scheduled and not during shutdown.
- *
- * @param peer_ctx The context of the peer to destroy.
- */
-static void
-schedule_peer_destruction (struct PeerContext *peer_ctx)
-{
-  GNUNET_assert (NULL != peer_ctx);
-  if (NULL != peer_ctx->destruction_task &&
-      GNUNET_NO == in_shutdown)
-  {
-    peer_ctx->destruction_task =
-      GNUNET_SCHEDULER_add_now (&destroy_peer,
-                               peer_ctx);
-  }
-}
-
-
-/**
- * @brief Remove peer
- *
- * @param peer the peer to clean
- * @return #GNUNET_YES if peer was removed
- *         #GNUNET_NO  otherwise
- */
-static int
-Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
-{
-  struct PeerContext *peer_ctx;
-
-  GNUNET_assert (NULL != peer_map);
-  if (GNUNET_NO ==
-      GNUNET_CONTAINER_multipeermap_contains (peer_map,
-                                             peer))
-  {
-    return GNUNET_NO;
-  }
-  peer_ctx = get_peer_ctx (peer);
-  set_peer_flag (peer_ctx, Peers_TO_DESTROY);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Going to remove peer %s\n",
-       GNUNET_i2s (&peer_ctx->peer_id));
-  Peers_unset_peer_flag (peer, Peers_ONLINE);
-
-  /* Clear list of pending operations */
-  // TODO this probably leaks memory
-  //      ('only' the cls to the function. Not sure what to do with it)
-  GNUNET_array_grow (peer_ctx->pending_ops,
-                    peer_ctx->num_pending_ops,
-                    0);
-  /* Remove all pending messages */
-  while (NULL != peer_ctx->pending_messages_head)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Removing unsent %s\n",
-        peer_ctx->pending_messages_head->type);
-    /* Cancle pending message, too */
-    if ( (NULL != peer_ctx->liveliness_check_pending) &&
-         (0 == memcmp (peer_ctx->pending_messages_head,
-                     peer_ctx->liveliness_check_pending,
-                     sizeof (struct PendingMessage))) )
-      {
-        // TODO this may leak memory
-        peer_ctx->liveliness_check_pending = NULL;
-      }
-    remove_pending_message (peer_ctx->pending_messages_head,
-                           GNUNET_YES);
-  }
-
-  /* If we are still waiting for notification whether this peer is live
-   * cancel the according task */
-  if (NULL != peer_ctx->liveliness_check_pending)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Removing pending liveliness check for peer %s\n",
-               GNUNET_i2s (&peer_ctx->peer_id));
-    // TODO wait until cadet sets mq->cancel_impl
-    //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
-    remove_pending_message (peer_ctx->liveliness_check_pending,
-                           GNUNET_YES);
-    peer_ctx->liveliness_check_pending = NULL;
-  }
-
-
-  /* Do we still have to wait for destruction of channels
-   * or issue the destruction? */
-  if (NULL != peer_ctx->send_channel_ctx &&
-      NULL != peer_ctx->send_channel_ctx->destruction_task)
-  {
-    schedule_peer_destruction (peer_ctx);
-    return GNUNET_NO;
-  }
-  if (NULL != peer_ctx->recv_channel_ctx &&
-      NULL != peer_ctx->recv_channel_ctx->destruction_task)
-  {
-    schedule_peer_destruction (peer_ctx);
-    return GNUNET_NO;
-  }
-  if (NULL != peer_ctx->recv_channel_ctx)
-  {
-    schedule_channel_destruction (peer_ctx->recv_channel_ctx);
-    schedule_peer_destruction (peer_ctx);
-    return GNUNET_NO;
-  }
-  if (NULL != peer_ctx->send_channel_ctx)
-  {
-    schedule_channel_destruction (peer_ctx->send_channel_ctx);
-    schedule_peer_destruction (peer_ctx);
-    return GNUNET_NO;
-  }
-
-  if (NULL != peer_ctx->destruction_task)
-  {
-    GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task);
-  }
-
-  if (GNUNET_YES !=
-      GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
-                                               &peer_ctx->peer_id))
-  {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-        "removing peer from peer_map failed\n");
-  }
-  GNUNET_free (peer_ctx);
-  return GNUNET_YES;
-}
-
-
-/**
- * @brief set flags on a given peer.
- *
- * @param peer the peer to set flags on
- * @param flags the flags
- */
-void
-Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags)
-{
-  struct PeerContext *peer_ctx;
-
-  peer_ctx = get_peer_ctx (peer);
-  set_peer_flag (peer_ctx, flags);
-}
-
-
-/**
- * @brief unset flags on a given peer.
- *
- * @param peer the peer to unset flags on
- * @param flags the flags
- */
-void
-Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags)
-{
-  struct PeerContext *peer_ctx;
-
-  peer_ctx = get_peer_ctx (peer);
-  unset_peer_flag (peer_ctx, flags);
-}
-
-
-/**
- * @brief Check whether flags on a peer are set.
- *
- * @param peer the peer to check the flag of
- * @param flags the flags to check
- *
- * @return #GNUNET_SYSERR if peer is not known
- *         #GNUNET_YES    if all given flags are set
- *         #GNUNET_NO     otherwise
- */
-int
-Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum 
Peers_PeerFlags flags)
-{
-  struct PeerContext *peer_ctx;
-
-  if (GNUNET_NO == Peers_check_peer_known (peer))
-  {
-    return GNUNET_SYSERR;
-  }
-  peer_ctx = get_peer_ctx (peer);
-  return check_peer_flag_set (peer_ctx, flags);
-}
-
-/**
- * @brief Check whether we have information about the given peer.
- *
- * FIXME probably deprecated. Make this the new _online.
- *
- * @param peer peer in question
- *
- * @return #GNUNET_YES if peer is known
- *         #GNUNET_NO  if peer is not knwon
- */
-int
-Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer)
-{
-  if (NULL != peer_map)
-  {
-    return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
-  } else
-  {
-    return GNUNET_NO;
-  }
-}
-
 
 /**
  * @brief Check whether @a peer is actually a peer.
@@ -1519,8 +1457,8 @@ Peers_check_peer_known (const struct GNUNET_PeerIdentity 
*peer)
  * @return #GNUNET_YES if peer is valid
  *         #GNUNET_NO  if peer is not valid
  */
-int
-Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer)
+static int
+check_peer_valid (const struct GNUNET_PeerIdentity *peer)
 {
   return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer);
 }
@@ -1533,10 +1471,10 @@ Peers_check_peer_valid (const struct 
GNUNET_PeerIdentity *peer)
  *
  * @param peer the peer to establish channel to
  */
-void
-Peers_indicate_sending_intention (const struct GNUNET_PeerIdentity *peer)
+static void
+indicate_sending_intention (const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
+  GNUNET_assert (GNUNET_YES == check_peer_known (peer));
   (void) get_channel (peer);
 }
 
@@ -1550,8 +1488,8 @@ Peers_indicate_sending_intention (const struct 
GNUNET_PeerIdentity *peer)
  * @return #GNUNET_YES if peer has the intention to send
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_check_peer_send_intention (const struct GNUNET_PeerIdentity *peer)
+static int
+check_peer_send_intention (const struct GNUNET_PeerIdentity *peer)
 {
   const struct PeerContext *peer_ctx;
 
@@ -1574,10 +1512,10 @@ Peers_check_peer_send_intention (const struct 
GNUNET_PeerIdentity *peer)
  * @return initial channel context for the channel
  *         (can be NULL -- that's not an error)
  */
-void *
-Peers_handle_inbound_channel (void *cls,
-                              struct GNUNET_CADET_Channel *channel,
-                              const struct GNUNET_PeerIdentity *initiator)
+static void *
+handle_inbound_channel (void *cls,
+                        struct GNUNET_CADET_Channel *channel,
+                        const struct GNUNET_PeerIdentity *initiator)
 {
   struct PeerContext *peer_ctx;
   struct GNUNET_PeerIdentity *ctx_peer;
@@ -1595,14 +1533,12 @@ Peers_handle_inbound_channel (void *cls,
   channel_ctx = add_channel_ctx (peer_ctx);
   channel_ctx->channel = channel;
   /* We only accept one incoming channel per peer */
-  if (GNUNET_YES == Peers_check_peer_send_intention (initiator))
+  if (GNUNET_YES == check_peer_send_intention (initiator))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Already got one receive channel. Destroying old one.\n");
     GNUNET_break_op (0);
-    GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel);
-    peer_ctx->recv_channel_ctx->channel = NULL;
-    remove_channel_ctx (peer_ctx->recv_channel_ctx);
+    destroy_channel (peer_ctx->recv_channel_ctx);
     peer_ctx->recv_channel_ctx = channel_ctx;
     /* return the channel context */
     return channel_ctx;
@@ -1620,12 +1556,12 @@ Peers_handle_inbound_channel (void *cls,
  * @return #GNUNET_YES if a sending channel towards that peer exists
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
+static int
+check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
-  if (GNUNET_NO == Peers_check_peer_known (peer))
+  if (GNUNET_NO == check_peer_known (peer))
   { /* If no such peer exists, there is no channel */
     return GNUNET_NO;
   }
@@ -1639,46 +1575,6 @@ Peers_check_sending_channel_exists (const struct 
GNUNET_PeerIdentity *peer)
 
 
 /**
- * @brief check whether the given channel is the sending channel of the given
- *        peer
- *
- * @param peer the peer in question
- * @param channel the channel to check for
- * @param role either #Peers_CHANNEL_ROLE_SENDING, or
- *                    #Peers_CHANNEL_ROLE_RECEIVING
- *
- * @return #GNUNET_YES if the given chennel is the sending channel of the peer
- *         #GNUNET_NO  otherwise
- */
-int
-Peers_check_channel_role (const struct GNUNET_PeerIdentity *peer,
-                          const struct GNUNET_CADET_Channel *channel,
-                          enum Peers_ChannelRole role)
-{
-  const struct PeerContext *peer_ctx;
-
-  if (GNUNET_NO == Peers_check_peer_known (peer))
-  {
-    return GNUNET_NO;
-  }
-  peer_ctx = get_peer_ctx (peer);
-  if ( (Peers_CHANNEL_ROLE_SENDING == role) &&
-       (NULL != peer_ctx->send_channel_ctx) &&
-       (channel == peer_ctx->send_channel_ctx->channel) )
-  {
-    return GNUNET_YES;
-  }
-  if ( (Peers_CHANNEL_ROLE_RECEIVING == role) &&
-       (NULL != peer_ctx->recv_channel_ctx) &&
-       (channel == peer_ctx->recv_channel_ctx->channel) )
-  {
-    return GNUNET_YES;
-  }
-  return GNUNET_NO;
-}
-
-
-/**
  * @brief Destroy the send channel of a peer e.g. stop indicating a sending
  *        intention to another peer
  *
@@ -1690,46 +1586,26 @@ Peers_check_channel_role (const struct 
GNUNET_PeerIdentity *peer,
  * @return #GNUNET_YES if channel was destroyed
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
+static int
+destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
-  if (GNUNET_NO == Peers_check_peer_known (peer))
+  if (GNUNET_NO == check_peer_known (peer))
   {
     return GNUNET_NO;
   }
   peer_ctx = get_peer_ctx (peer);
   if (NULL != peer_ctx->send_channel_ctx)
   {
-    schedule_channel_destruction (peer_ctx->send_channel_ctx);
-    (void) Peers_check_connected (peer);
+    destroy_channel (peer_ctx->send_channel_ctx);
+    (void) check_connected (peer);
     return GNUNET_YES;
   }
   return GNUNET_NO;
 }
 
 /**
- * @brief Callback for scheduler to destroy a channel
- *
- * @param cls Context of the channel
- */
-static void
-destroy_channel (void *cls)
-{
-  struct ChannelCtx *channel_ctx = cls;
-  struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
-
-  GNUNET_assert (channel_ctx == peer_ctx->send_channel_ctx ||
-                 channel_ctx == peer_ctx->recv_channel_ctx);
-
-  channel_ctx->destruction_task = NULL;
-  GNUNET_CADET_channel_destroy (channel_ctx->channel);
-  remove_channel_ctx (peer_ctx->send_channel_ctx);
-}
-
-
-/**
  * @brief Send a message to another peer.
  *
  * Keeps track about pending messages so they can be properly removed when the
@@ -1739,10 +1615,10 @@ destroy_channel (void *cls)
  * @param ev envelope of the message
  * @param type type of the message
  */
-void
-Peers_send_message (const struct GNUNET_PeerIdentity *peer,
-                    struct GNUNET_MQ_Envelope *ev,
-                    const char *type)
+static void
+send_message (const struct GNUNET_PeerIdentity *peer,
+              struct GNUNET_MQ_Envelope *ev,
+              const char *type)
 {
   struct PendingMessage *pending_msg;
   struct GNUNET_MQ_Handle *mq;
@@ -1769,14 +1645,14 @@ Peers_send_message (const struct GNUNET_PeerIdentity 
*peer,
  * @return #GNUNET_YES if the operation was scheduled
  *         #GNUNET_NO  otherwise
  */
-int
-Peers_schedule_operation (const struct GNUNET_PeerIdentity *peer,
+static int
+schedule_operation (const struct GNUNET_PeerIdentity *peer,
                           const PeerOp peer_op)
 {
   struct PeerPendingOp pending_op;
   struct PeerContext *peer_ctx;
 
-  GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
+  GNUNET_assert (GNUNET_YES == check_peer_known (peer));
 
   //TODO if LIVE/ONLINE execute immediately
 
@@ -1793,24 +1669,6 @@ Peers_schedule_operation (const struct 
GNUNET_PeerIdentity *peer,
   return GNUNET_NO;
 }
 
-/**
- * @brief Get the recv_channel of @a peer.
- * Needed to correctly handle (call #GNUNET_CADET_receive_done()) incoming
- * messages.
- *
- * @param peer The peer to get the recv_channel from.
- *
- * @return The recv_channel.
- */
-struct GNUNET_CADET_Channel *
-Peers_get_recv_channel (const struct GNUNET_PeerIdentity *peer)
-{
-  struct PeerContext *peer_ctx;
-
-  GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
-  peer_ctx = get_peer_ctx (peer);
-  return peer_ctx->recv_channel_ctx->channel;
-}
 /***********************************************************************
  * /Old gnunet-service-rps_peers.c
 ***********************************************************************/
@@ -2266,16 +2124,16 @@ insert_in_view (const struct GNUNET_PeerIdentity *peer)
 {
   int online;
 
-  online = Peers_check_peer_flag (peer, Peers_ONLINE);
+  online = check_peer_flag (peer, Peers_ONLINE);
   if ( (GNUNET_NO == online) ||
        (GNUNET_SYSERR == online) ) /* peer is not even known */
   {
-    (void) Peers_issue_peer_liveliness_check (peer);
-    (void) Peers_schedule_operation (peer, insert_in_view_op);
+    (void) issue_peer_liveliness_check (peer);
+    (void) schedule_operation (peer, insert_in_view_op);
     return GNUNET_NO;
   }
   /* Open channel towards peer to keep connection open */
-  Peers_indicate_sending_intention (peer);
+  indicate_sending_intention (peer);
   return View_put (peer);
 }
 
@@ -2468,7 +2326,7 @@ send_pull_reply (const struct GNUNET_PeerIdentity 
*peer_id,
   GNUNET_memcpy (&out_msg[1], peer_ids,
          send_size * sizeof (struct GNUNET_PeerIdentity));
 
-  Peers_send_message (peer_id, ev, "PULL REPLY");
+  send_message (peer_id, ev, "PULL REPLY");
   GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO);
   // TODO check with send intention: as send_channel is used/opened we indicate
   // a sending intention without intending it.
@@ -2519,10 +2377,10 @@ insert_in_sampler (void *cls,
   if (0 < RPS_sampler_count_id (prot_sampler, peer))
   {
     /* Make sure we 'know' about this peer */
-    (void) Peers_issue_peer_liveliness_check (peer);
+    (void) issue_peer_liveliness_check (peer);
     /* Establish a channel towards that peer to indicate we are going to send
      * messages to it */
-    //Peers_indicate_sending_intention (peer);
+    //indicate_sending_intention (peer);
   }
   #ifdef TO_FILE
   num_observed_peers++;
@@ -2554,10 +2412,10 @@ static void
 got_peer (const struct GNUNET_PeerIdentity *peer)
 {
   /* If we did not know this peer already, insert it into sampler and view */
-  if (GNUNET_YES == Peers_issue_peer_liveliness_check (peer))
+  if (GNUNET_YES == issue_peer_liveliness_check (peer))
   {
-    Peers_schedule_operation (peer, insert_in_sampler);
-    Peers_schedule_operation (peer, insert_in_view_op);
+    schedule_operation (peer, insert_in_sampler);
+    schedule_operation (peer, insert_in_view_op);
   }
 }
 
@@ -2572,17 +2430,17 @@ static int
 check_sending_channel_needed (const struct GNUNET_PeerIdentity *peer)
 {
   /* struct GNUNET_CADET_Channel *channel; */
-  if (GNUNET_NO == Peers_check_peer_known (peer))
+  if (GNUNET_NO == check_peer_known (peer))
   {
     return GNUNET_NO;
   }
-  if (GNUNET_YES == Peers_check_sending_channel_exists (peer))
+  if (GNUNET_YES == check_sending_channel_exists (peer))
   {
     if ( (0 < RPS_sampler_count_id (prot_sampler, peer)) ||
          (GNUNET_YES == View_contains_peer (peer)) ||
          (GNUNET_YES == CustomPeerMap_contains_peer (push_map, peer)) ||
          (GNUNET_YES == CustomPeerMap_contains_peer (pull_map, peer)) ||
-         (GNUNET_YES == Peers_check_peer_flag (peer, 
Peers_PULL_REPLY_PENDING)))
+         (GNUNET_YES == check_peer_flag (peer, Peers_PULL_REPLY_PENDING)))
     { /* If we want to keep the connection to peer open */
       return GNUNET_YES;
     }
@@ -2605,7 +2463,7 @@ remove_peer (const struct GNUNET_PeerIdentity *peer)
   CustomPeerMap_remove_peer (push_map, peer);
   RPS_sampler_reinitialise_by_value (prot_sampler, peer);
   RPS_sampler_reinitialise_by_value (client_sampler, peer);
-  schedule_peer_destruction (get_peer_ctx (peer));
+  destroy_peer (get_peer_ctx (peer));
 }
 
 
@@ -2626,19 +2484,19 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
         GNUNET_i2s (peer));
     #ifdef ENABLE_MALICIOUS
     if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer, peer))
-      (void) Peers_destroy_sending_channel (peer);
+      (void) destroy_sending_channel (peer);
     #else /* ENABLE_MALICIOUS */
-    (void) Peers_destroy_sending_channel (peer);
+    (void) destroy_sending_channel (peer);
     #endif /* ENABLE_MALICIOUS */
   }
 
-  if ( (GNUNET_NO == Peers_check_peer_send_intention (peer)) &&
+  if ( (GNUNET_NO == check_peer_send_intention (peer)) &&
        (GNUNET_NO == View_contains_peer (peer)) &&
        (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
        (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
        (0 == RPS_sampler_count_id (prot_sampler,   peer)) &&
        (0 == RPS_sampler_count_id (client_sampler, peer)) &&
-       (GNUNET_NO != Peers_check_removable (peer)) )
+       (GNUNET_NO != check_removable (peer)) )
   { /* We can safely remove this peer */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Going to remove peer %s\n",
@@ -2648,53 +2506,6 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
   }
 }
 
-/**
- * @brief Allocate memory for a new channel context and insert it into DLL
- *
- * @param peer_ctx context of the according peer
- *
- * @return The channel context
- */
-static struct ChannelCtx *
-add_channel_ctx (struct PeerContext *peer_ctx)
-{
-  struct ChannelCtx *channel_ctx;
-  channel_ctx = GNUNET_new (struct ChannelCtx);
-  channel_ctx->peer_ctx = peer_ctx;
-  return channel_ctx;
-}
-
-
-/**
- * @brief Remove the channel context from the DLL and free the memory.
- *
- * @param channel_ctx The channel context.
- */
-static void
-remove_channel_ctx (struct ChannelCtx *channel_ctx)
-{
-  struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
-
-  if (NULL != channel_ctx->destruction_task)
-  {
-    GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
-  }
-  GNUNET_free (channel_ctx);
-  if (channel_ctx == peer_ctx->send_channel_ctx)
-  {
-    peer_ctx->send_channel_ctx = NULL;
-    peer_ctx->mq = NULL;
-  }
-  else if (channel_ctx == peer_ctx->recv_channel_ctx)
-  {
-    peer_ctx->recv_channel_ctx = NULL;
-  }
-  else
-  {
-    GNUNET_assert (0);
-  }
-}
-
 
 /**
  * @brief This is called when a channel is destroyed.
@@ -3184,7 +2995,7 @@ handle_peer_push (void *cls,
   /* Add the sending peer to the push_map */
   CustomPeerMap_put (push_map, peer);
 
-  GNUNET_break_op (Peers_check_peer_known (peer));
+  GNUNET_break_op (check_peer_known (peer));
   GNUNET_CADET_receive_done (channel_ctx->channel);
 }
 
@@ -3224,7 +3035,7 @@ handle_peer_pull_request (void *cls,
   }
   #endif /* ENABLE_MALICIOUS */
 
-  GNUNET_break_op (Peers_check_peer_known (peer));
+  GNUNET_break_op (check_peer_known (peer));
   GNUNET_CADET_receive_done (channel_ctx->channel);
   view_array = View_get_as_array ();
   send_pull_reply (peer, view_array, View_size ());
@@ -3262,7 +3073,7 @@ check_peer_pull_reply (void *cls,
     return GNUNET_SYSERR;
   }
 
-  if (GNUNET_YES != Peers_check_peer_flag (sender, Peers_PULL_REPLY_PENDING))
+  if (GNUNET_YES != check_peer_flag (sender, Peers_PULL_REPLY_PENDING))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Received a pull reply from a peer (%s) we didn't request one from!\n",
@@ -3336,23 +3147,23 @@ handle_peer_pull_reply (void *cls,
     }
     #endif /* ENABLE_MALICIOUS */
     /* Make sure we 'know' about this peer */
-    (void) Peers_insert_peer (&peers[i]);
+    (void) insert_peer (&peers[i]);
 
-    if (GNUNET_YES == Peers_check_peer_valid (&peers[i]))
+    if (GNUNET_YES == check_peer_valid (&peers[i]))
     {
       CustomPeerMap_put (pull_map, &peers[i]);
     }
     else
     {
-      Peers_schedule_operation (&peers[i], insert_in_pull_map);
-      (void) Peers_issue_peer_liveliness_check (&peers[i]);
+      schedule_operation (&peers[i], insert_in_pull_map);
+      (void) issue_peer_liveliness_check (&peers[i]);
     }
   }
 
-  Peers_unset_peer_flag (sender, Peers_PULL_REPLY_PENDING);
+  UNSET_PEER_FLAG (get_peer_ctx (sender), Peers_PULL_REPLY_PENDING);
   clean_peer (sender);
 
-  GNUNET_break_op (Peers_check_peer_known (sender));
+  GNUNET_break_op (check_peer_known (sender));
   GNUNET_CADET_receive_done (channel_ctx->channel);
 }
 
@@ -3416,16 +3227,16 @@ send_pull_request (const struct GNUNET_PeerIdentity 
*peer)
 {
   struct GNUNET_MQ_Envelope *ev;
 
-  GNUNET_assert (GNUNET_NO == Peers_check_peer_flag (peer,
+  GNUNET_assert (GNUNET_NO == check_peer_flag (peer,
                                                      
Peers_PULL_REPLY_PENDING));
-  Peers_set_peer_flag (peer, Peers_PULL_REPLY_PENDING);
+  SET_PEER_FLAG (get_peer_ctx (peer), Peers_PULL_REPLY_PENDING);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Going to send PULL REQUEST to peer %s.\n",
        GNUNET_i2s (peer));
 
   ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST);
-  Peers_send_message (peer, ev, "PULL REQUEST");
+  send_message (peer, ev, "PULL REQUEST");
   GNUNET_STATISTICS_update(stats, "# pull request send issued", 1, GNUNET_NO);
 }
 
@@ -3445,7 +3256,7 @@ send_push (const struct GNUNET_PeerIdentity *peer_id)
        GNUNET_i2s (peer_id));
 
   ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH);
-  Peers_send_message (peer_id, ev, "PUSH");
+  send_message (peer_id, ev, "PUSH");
   GNUNET_STATISTICS_update(stats, "# push send issued", 1, GNUNET_NO);
 }
 
@@ -3569,9 +3380,9 @@ handle_client_act_malicious (void *cls,
             &msg->attacked_peer,
             sizeof (struct GNUNET_PeerIdentity));
     /* Set the flag of the attacked peer to valid to avoid problems */
-    if (GNUNET_NO == Peers_check_peer_known (&attacked_peer))
+    if (GNUNET_NO == check_peer_known (&attacked_peer))
     {
-      (void) Peers_issue_peer_liveliness_check (&attacked_peer);
+      (void) issue_peer_liveliness_check (&attacked_peer);
     }
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3661,8 +3472,8 @@ do_mal_round (void *cls)
      * Send as many pushes to the attacked peer as possible
      * That is one push per round as it will ignore more.
      */
-    (void) Peers_issue_peer_liveliness_check (&attacked_peer);
-    if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_ONLINE))
+    (void) issue_peer_liveliness_check (&attacked_peer);
+    if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
       send_push (&attacked_peer);
   }
 
@@ -3671,10 +3482,10 @@ do_mal_round (void *cls)
   { /* Combined attack */
 
     /* Send PUSH to attacked peers */
-    if (GNUNET_YES == Peers_check_peer_known (&attacked_peer))
+    if (GNUNET_YES == check_peer_known (&attacked_peer))
     {
-      (void) Peers_issue_peer_liveliness_check (&attacked_peer);
-      if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_ONLINE))
+      (void) issue_peer_liveliness_check (&attacked_peer);
+      if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
             "Goding to send push to attacked peer (%s)\n",
@@ -3682,7 +3493,7 @@ do_mal_round (void *cls)
         send_push (&attacked_peer);
       }
     }
-    (void) Peers_issue_peer_liveliness_check (&attacked_peer);
+    (void) issue_peer_liveliness_check (&attacked_peer);
 
     /* The maximum of pushes we're going to send this round */
     num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1,
@@ -3799,7 +3610,7 @@ do_round (void *cls)
     for (i = first_border; i < second_border; i++)
     {
       peer = view_array[permut[i]];
-      if ( GNUNET_NO == Peers_check_peer_flag (&peer, 
Peers_PULL_REPLY_PENDING))
+      if ( GNUNET_NO == check_peer_flag (&peer, Peers_PULL_REPLY_PENDING))
       { // FIXME if this fails schedule/loop this for later
         send_pull_request (&peer);
       }
@@ -4098,13 +3909,14 @@ shutdown_task (void *cls)
     do_round_task = NULL;
   }
 
-  Peers_terminate ();
+  peers_terminate ();
 
   GNUNET_NSE_disconnect (nse);
   RPS_sampler_destroy (prot_sampler);
   RPS_sampler_destroy (client_sampler);
   GNUNET_CADET_close_port (cadet_port);
   GNUNET_CADET_disconnect (cadet_handle);
+  cadet_handle = NULL;
   View_destroy ();
   CustomPeerMap_destroy (push_map);
   CustomPeerMap_destroy (pull_map);
@@ -4315,7 +4127,7 @@ run (void *cls,
                       &port);
   cadet_port = GNUNET_CADET_open_port (cadet_handle,
                                        &port,
-                                       &Peers_handle_inbound_channel, /* 
Connect handler */
+                                       &handle_inbound_channel, /* Connect 
handler */
                                        NULL, /* cls */
                                        NULL, /* WindowSize handler */
                                        &cleanup_destroyed_channel, /* 
Disconnect handler */
@@ -4330,7 +4142,7 @@ run (void *cls,
 
 
   peerinfo_handle = GNUNET_PEERINFO_connect (cfg);
-  Peers_initialise (fn_valid_peers, cadet_handle);
+  initialise_peers (fn_valid_peers, cadet_handle);
   GNUNET_free (fn_valid_peers);
 
   /* Initialise sampler */
@@ -4353,7 +4165,7 @@ run (void *cls,
   // TODO send push/pull to each of those peers?
   // TODO read stored valid peers from last run
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting stored valid peers\n");
-  Peers_get_valid_peers (valid_peers_iterator, NULL);
+  get_valid_peers (valid_peers_iterator, NULL);
 
   peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg,
                                                    GNUNET_NO,
diff --git a/src/rps/gnunet-service-rps_custommap.c 
b/src/rps/gnunet-service-rps_custommap.c
index 9e003eb39..3513ff8da 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -202,6 +202,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap 
*c_peer_map,
   p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index);
   GNUNET_assert (NULL != p);
   GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index);
+  // TODO wrong peerid?
   GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer);
   if (*index != CustomPeerMap_size (c_peer_map))
   { /* fill 'gap' with peer at last index */
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 08fe96097..ed682c251 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -239,7 +239,7 @@ to_file_raw_unaligned (const char *file_name,
     /* needed bits of the input byte that have not been moved */
     char byte_input_leftover;
     unsigned num_bits_leftover;
-    unsigned num_bits_discard;
+    //unsigned num_bits_discard;
     char byte_unaligned_new;
 
     if ( (bits_needed - (i * 8)) <= 8)
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 08424022f..92d8c12ea 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -2850,7 +2850,7 @@ main (int argc, char *argv[])
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
     cur_test_run.name = "test-rps-profiler";
-    num_peers = 100;
+    num_peers = 16;
     mal_type = 3;
     cur_test_run.init_peer = profiler_init_peer;
     //cur_test_run.pre_test = mal_pre;
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index 05bb9f444..02fbf76a4 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -1,5 +1,6 @@
 [rps]
 #PREFIX = valgrind --leak-check=full --show-leak-kinds=all 
--log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
+#PREFIX = valgrind --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
 #BINARY = gnunet-service-rps
 UNIXPATH = $GNUNET_TMP/gnunet-service-rps.sock
 HOME = $SERVICEHOME

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]