aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-29 14:20:22 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-29 14:20:22 +0000
commit8459c76076092899a74aa7e4451ed24faf91684b (patch)
treef66e960ec08f0270387afcbed3e10ea2cb04d6cd
parent6486831b520ad18632aa117ee8c15305d6b89c29 (diff)
downloadgnunet-8459c76076092899a74aa7e4451ed24faf91684b.tar.gz
gnunet-8459c76076092899a74aa7e4451ed24faf91684b.zip
-preparations for replacement of try_connect call
-rw-r--r--src/core/Makefile.am5
-rw-r--r--src/core/test_core_api.c83
-rw-r--r--src/core/test_core_api_reliability.c91
-rw-r--r--src/core/test_core_quota_compliance.c152
4 files changed, 181 insertions, 150 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 63e374005..be855b453 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -82,6 +82,7 @@ test_core_api_SOURCES = \
82test_core_api_LDADD = \ 82test_core_api_LDADD = \
83 libgnunetcore.la \ 83 libgnunetcore.la \
84 $(top_builddir)/src/transport/libgnunettransport.la \ 84 $(top_builddir)/src/transport/libgnunettransport.la \
85 $(top_builddir)/src/ats/libgnunetats.la \
85 $(top_builddir)/src/util/libgnunetutil.la 86 $(top_builddir)/src/util/libgnunetutil.la
86 87
87test_core_api_reliability_SOURCES = \ 88test_core_api_reliability_SOURCES = \
@@ -89,6 +90,7 @@ test_core_api_reliability_SOURCES = \
89test_core_api_reliability_LDADD = \ 90test_core_api_reliability_LDADD = \
90 libgnunetcore.la \ 91 libgnunetcore.la \
91 $(top_builddir)/src/transport/libgnunettransport.la \ 92 $(top_builddir)/src/transport/libgnunettransport.la \
93 $(top_builddir)/src/ats/libgnunetats.la \
92 $(top_builddir)/src/util/libgnunetutil.la 94 $(top_builddir)/src/util/libgnunetutil.la
93 95
94test_core_api_send_to_self_SOURCES = \ 96test_core_api_send_to_self_SOURCES = \
@@ -119,6 +121,7 @@ test_core_quota_compliance_symmetric_SOURCES = \
119test_core_quota_compliance_symmetric_LDADD = \ 121test_core_quota_compliance_symmetric_LDADD = \
120 libgnunetcore.la \ 122 libgnunetcore.la \
121 $(top_builddir)/src/transport/libgnunettransport.la \ 123 $(top_builddir)/src/transport/libgnunettransport.la \
124 $(top_builddir)/src/ats/libgnunetats.la \
122 $(top_builddir)/src/util/libgnunetutil.la \ 125 $(top_builddir)/src/util/libgnunetutil.la \
123 $(top_builddir)/src/statistics/libgnunetstatistics.la 126 $(top_builddir)/src/statistics/libgnunetstatistics.la
124 127
@@ -127,6 +130,7 @@ test_core_quota_compliance_asymmetric_send_limited_SOURCES = \
127test_core_quota_compliance_asymmetric_send_limited_LDADD = \ 130test_core_quota_compliance_asymmetric_send_limited_LDADD = \
128 libgnunetcore.la \ 131 libgnunetcore.la \
129 $(top_builddir)/src/transport/libgnunettransport.la \ 132 $(top_builddir)/src/transport/libgnunettransport.la \
133 $(top_builddir)/src/ats/libgnunetats.la \
130 $(top_builddir)/src/util/libgnunetutil.la \ 134 $(top_builddir)/src/util/libgnunetutil.la \
131 $(top_builddir)/src/statistics/libgnunetstatistics.la 135 $(top_builddir)/src/statistics/libgnunetstatistics.la
132 136
@@ -135,6 +139,7 @@ test_core_quota_compliance_asymmetric_recv_limited_SOURCES = \
135test_core_quota_compliance_asymmetric_recv_limited_LDADD = \ 139test_core_quota_compliance_asymmetric_recv_limited_LDADD = \
136 libgnunetcore.la \ 140 libgnunetcore.la \
137 $(top_builddir)/src/transport/libgnunettransport.la \ 141 $(top_builddir)/src/transport/libgnunettransport.la \
142 $(top_builddir)/src/ats/libgnunetats.la \
138 $(top_builddir)/src/util/libgnunetutil.la \ 143 $(top_builddir)/src/util/libgnunetutil.la \
139 $(top_builddir)/src/statistics/libgnunetstatistics.la 144 $(top_builddir)/src/statistics/libgnunetstatistics.la
140 145
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 6f946e2fa..b1c6c8212 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2009, 2010, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -24,11 +24,9 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_arm_service.h" 25#include "gnunet_arm_service.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_os_lib.h"
29#include "gnunet_program_lib.h"
30#include "gnunet_scheduler_lib.h"
31#include "gnunet_transport_service.h" 28#include "gnunet_transport_service.h"
29#include "gnunet_ats_service.h"
32 30
33#define MTYPE 12345 31#define MTYPE 12345
34 32
@@ -39,6 +37,8 @@ struct PeerContext
39 struct GNUNET_PeerIdentity id; 37 struct GNUNET_PeerIdentity id;
40 struct GNUNET_TRANSPORT_Handle *th; 38 struct GNUNET_TRANSPORT_Handle *th;
41 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 39 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
40 struct GNUNET_ATS_ConnectivityHandle *ats;
41 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
42 struct GNUNET_MessageHeader *hello; 42 struct GNUNET_MessageHeader *hello;
43 int connect_status; 43 int connect_status;
44 struct GNUNET_OS_Process *arm_proc; 44 struct GNUNET_OS_Process *arm_proc;
@@ -48,9 +48,9 @@ static struct PeerContext p1;
48 48
49static struct PeerContext p2; 49static struct PeerContext p2;
50 50
51static struct GNUNET_SCHEDULER_Task * err_task; 51static struct GNUNET_SCHEDULER_Task *err_task;
52 52
53static struct GNUNET_SCHEDULER_Task * con_task; 53static struct GNUNET_SCHEDULER_Task *con_task;
54 54
55static int ok; 55static int ok;
56 56
@@ -74,22 +74,39 @@ process_hello (void *cls,
74 74
75 75
76static void 76static void
77terminate_peer (struct PeerContext *p)
78{
79 if (NULL != p->ch)
80 {
81 GNUNET_CORE_disconnect (p->ch);
82 p->ch = NULL;
83 }
84 if (NULL != p->th)
85 {
86 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
87 GNUNET_TRANSPORT_disconnect (p->th);
88 p->th = NULL;
89 }
90 if (NULL != p->ats_sh)
91 {
92 GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
93 p->ats_sh = NULL;
94 }
95 if (NULL != p->ats)
96 {
97 GNUNET_ATS_connectivity_done (p->ats);
98 p->ats = NULL;
99 }
100}
101
102
103static void
77terminate_task (void *cls, 104terminate_task (void *cls,
78 const struct GNUNET_SCHEDULER_TaskContext *tc) 105 const struct GNUNET_SCHEDULER_TaskContext *tc)
79{ 106{
80 GNUNET_assert (ok == 6); 107 GNUNET_assert (ok == 6);
81 GNUNET_CORE_disconnect (p1.ch); 108 terminate_peer (&p1);
82 p1.ch = NULL; 109 terminate_peer (&p2);
83 GNUNET_CORE_disconnect (p2.ch);
84 p2.ch = NULL;
85 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
86 p1.ghh = NULL;
87 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
88 p2.ghh = NULL;
89 GNUNET_TRANSPORT_disconnect (p1.th);
90 p1.th = NULL;
91 GNUNET_TRANSPORT_disconnect (p2.th);
92 p2.th = NULL;
93 if (NULL != con_task) 110 if (NULL != con_task)
94 { 111 {
95 GNUNET_SCHEDULER_cancel (con_task); 112 GNUNET_SCHEDULER_cancel (con_task);
@@ -107,28 +124,8 @@ terminate_task_error (void *cls,
107 "ENDING ANGRILY %u\n", 124 "ENDING ANGRILY %u\n",
108 ok); 125 ok);
109 GNUNET_break (0); 126 GNUNET_break (0);
110 if (NULL != p1.ch) 127 terminate_peer (&p1);
111 { 128 terminate_peer (&p2);
112 GNUNET_CORE_disconnect (p1.ch);
113 p1.ch = NULL;
114 }
115 if (NULL != p2.ch)
116 {
117 GNUNET_CORE_disconnect (p2.ch);
118 p2.ch = NULL;
119 }
120 if (p1.th != NULL)
121 {
122 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
123 GNUNET_TRANSPORT_disconnect (p1.th);
124 p1.th = NULL;
125 }
126 if (p2.th != NULL)
127 {
128 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
129 GNUNET_TRANSPORT_disconnect (p2.th);
130 p2.th = NULL;
131 }
132 if (NULL != con_task) 129 if (NULL != con_task)
133 { 130 {
134 GNUNET_SCHEDULER_cancel (con_task); 131 GNUNET_SCHEDULER_cancel (con_task);
@@ -317,7 +314,9 @@ setup_peer (struct PeerContext *p,
317 "-c", cfgname, NULL); 314 "-c", cfgname, NULL);
318 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 315 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
319 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); 316 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
320 GNUNET_assert (p->th != NULL); 317 GNUNET_assert (NULL != p->th);
318 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
319 GNUNET_assert (NULL != p->ats);
321 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 320 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
322 GNUNET_free (binary); 321 GNUNET_free (binary);
323} 322}
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index bd55565e3..dfea0cdcc 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -24,10 +24,8 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_arm_service.h" 25#include "gnunet_arm_service.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_os_lib.h" 28#include "gnunet_ats_service.h"
29#include "gnunet_program_lib.h"
30#include "gnunet_scheduler_lib.h"
31#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
32#include <gauger.h> 30#include <gauger.h>
33 31
@@ -68,6 +66,8 @@ struct PeerContext
68 struct GNUNET_TRANSPORT_Handle *th; 66 struct GNUNET_TRANSPORT_Handle *th;
69 struct GNUNET_MessageHeader *hello; 67 struct GNUNET_MessageHeader *hello;
70 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 68 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
69 struct GNUNET_ATS_ConnectivityHandle *ats;
70 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
71 int connect_status; 71 int connect_status;
72 struct GNUNET_OS_Process *arm_proc; 72 struct GNUNET_OS_Process *arm_proc;
73}; 73};
@@ -103,30 +103,48 @@ get_size (unsigned int iter)
103 103
104 104
105static void 105static void
106process_hello (void *cls, const struct GNUNET_MessageHeader *message); 106terminate_peer (struct PeerContext *p)
107{
108 if (NULL != p->ch)
109 {
110 GNUNET_CORE_disconnect (p->ch);
111 p->ch = NULL;
112 }
113 if (NULL != p->th)
114 {
115 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
116 GNUNET_TRANSPORT_disconnect (p->th);
117 p->th = NULL;
118 }
119 if (NULL != p->ats_sh)
120 {
121 GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
122 p->ats_sh = NULL;
123 }
124 if (NULL != p->ats)
125 {
126 GNUNET_ATS_connectivity_done (p->ats);
127 p->ats = NULL;
128 }
129}
107 130
108 131
109static void 132static void
110terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 133terminate_task (void *cls,
134 const struct GNUNET_SCHEDULER_TaskContext *tc)
111{ 135{
112 unsigned long long delta; 136 unsigned long long delta;
113 137
114 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); 138 terminate_peer (&p1);
115 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); 139 terminate_peer (&p2);
116 GNUNET_CORE_disconnect (p1.ch); 140 if (NULL != connect_task)
117 p1.ch = NULL; 141 {
118 GNUNET_free_non_null (p1.hello);
119 GNUNET_CORE_disconnect (p2.ch);
120 p2.ch = NULL;
121 GNUNET_free_non_null (p2.hello);
122 if (connect_task != NULL)
123 GNUNET_SCHEDULER_cancel (connect_task); 142 GNUNET_SCHEDULER_cancel (connect_task);
124 GNUNET_TRANSPORT_disconnect (p1.th); 143 connect_task = NULL;
125 p1.th = NULL; 144 }
126 GNUNET_TRANSPORT_disconnect (p2.th);
127 p2.th = NULL;
128 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; 145 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
129 FPRINTF (stderr, "\nThroughput was %llu kb/s\n", 146 FPRINTF (stderr,
147 "\nThroughput was %llu kb/s\n",
130 total_bytes * 1000000LL / 1024 / delta); 148 total_bytes * 1000000LL / 1024 / delta);
131 GAUGER ("CORE", "Core throughput/s", total_bytes * 1000000LL / 1024 / delta, 149 GAUGER ("CORE", "Core throughput/s", total_bytes * 1000000LL / 1024 / delta,
132 "kb/s"); 150 "kb/s");
@@ -135,39 +153,24 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
135 153
136 154
137static void 155static void
138terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 156terminate_task_error (void *cls,
157 const struct GNUNET_SCHEDULER_TaskContext *tc)
139{ 158{
140 GNUNET_break (0); 159 GNUNET_break (0);
141 if (p1.ch != NULL) 160 terminate_peer (&p1);
142 { 161 terminate_peer (&p2);
143 GNUNET_CORE_disconnect (p1.ch); 162 if (NULL != connect_task)
144 p1.ch = NULL;
145 }
146 if (p2.ch != NULL)
147 { 163 {
148 GNUNET_CORE_disconnect (p2.ch);
149 p2.ch = NULL;
150 }
151 if (connect_task != NULL)
152 GNUNET_SCHEDULER_cancel (connect_task); 164 GNUNET_SCHEDULER_cancel (connect_task);
153 if (p1.th != NULL) 165 connect_task = NULL;
154 {
155 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
156 GNUNET_TRANSPORT_disconnect (p1.th);
157 p1.th = NULL;
158 }
159 if (p2.th != NULL)
160 {
161 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
162 GNUNET_TRANSPORT_disconnect (p2.th);
163 p2.th = NULL;
164 } 166 }
165 ok = 42; 167 ok = 42;
166} 168}
167 169
168 170
169static void 171static void
170try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 172try_connect (void *cls,
173 const struct GNUNET_SCHEDULER_TaskContext *tc)
171{ 174{
172 connect_task = 175 connect_task =
173 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, 176 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
@@ -435,6 +438,8 @@ setup_peer (struct PeerContext *p, const char *cfgname)
435 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 438 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
436 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); 439 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
437 GNUNET_assert (p->th != NULL); 440 GNUNET_assert (p->th != NULL);
441 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
442 GNUNET_assert (NULL != p->ats);
438 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 443 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
439 GNUNET_free (binary); 444 GNUNET_free (binary);
440} 445}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index bc71aa5d7..ce62dbe3b 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2009, 2010, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -24,10 +24,8 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_arm_service.h" 25#include "gnunet_arm_service.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_os_lib.h" 28#include "gnunet_ats_service.h"
29#include "gnunet_program_lib.h"
30#include "gnunet_scheduler_lib.h"
31#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
32#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
33 31
@@ -62,11 +60,11 @@ static unsigned long long total_bytes_recv;
62 60
63static struct GNUNET_TIME_Absolute start_time; 61static struct GNUNET_TIME_Absolute start_time;
64 62
65static struct GNUNET_SCHEDULER_Task * err_task; 63static struct GNUNET_SCHEDULER_Task *err_task;
66 64
67static struct GNUNET_SCHEDULER_Task * measure_task; 65static struct GNUNET_SCHEDULER_Task *measure_task;
68 66
69static struct GNUNET_SCHEDULER_Task * connect_task; 67static struct GNUNET_SCHEDULER_Task *connect_task;
70 68
71 69
72struct PeerContext 70struct PeerContext
@@ -79,6 +77,8 @@ struct PeerContext
79 struct GNUNET_MessageHeader *hello; 77 struct GNUNET_MessageHeader *hello;
80 struct GNUNET_STATISTICS_Handle *stats; 78 struct GNUNET_STATISTICS_Handle *stats;
81 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 79 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
80 struct GNUNET_ATS_ConnectivityHandle *ats;
81 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
82 int connect_status; 82 int connect_status;
83 struct GNUNET_OS_Process *arm_proc; 83 struct GNUNET_OS_Process *arm_proc;
84}; 84};
@@ -110,85 +110,93 @@ struct TestMessage
110 uint32_t num; 110 uint32_t num;
111}; 111};
112 112
113static void
114process_hello (void *cls, const struct GNUNET_MessageHeader *message);
115 113
116static void 114static void
117terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 115terminate_peer (struct PeerContext *p)
118{ 116{
119 struct GNUNET_CORE_Handle *ch; 117 if (p->nth != NULL)
118 {
119 GNUNET_CORE_notify_transmit_ready_cancel (p->nth);
120 p->nth = NULL;
121 }
122 if (NULL != p->ch)
123 {
124 GNUNET_CORE_disconnect (p->ch);
125 p->ch = NULL;
126 }
127 if (NULL != p->th)
128 {
129 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
130 GNUNET_TRANSPORT_disconnect (p->th);
131 p->th = NULL;
132 }
133 if (NULL != p->ats_sh)
134 {
135 GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
136 p->ats_sh = NULL;
137 }
138 if (NULL != p->ats)
139 {
140 GNUNET_ATS_connectivity_done (p->ats);
141 p->ats = NULL;
142 }
143 if (NULL != p->stats)
144 {
145 GNUNET_STATISTICS_destroy (p->stats, GNUNET_NO);
146 p->stats = NULL;
147 }
148 if (NULL != p->hello)
149 {
150 GNUNET_free (p->hello);
151 p->hello = NULL;
152 }
153}
120 154
155
156static void
157terminate_task (void *cls,
158 const struct GNUNET_SCHEDULER_TaskContext *tc)
159{
121 err_task = NULL; 160 err_task = NULL;
122 GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO); 161 terminate_peer (&p1);
123 GNUNET_STATISTICS_destroy (p2.stats, GNUNET_NO); 162 terminate_peer (&p2);
124 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); 163 if (NULL != connect_task)
125 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
126 if (p1.nth != NULL)
127 {
128 GNUNET_CORE_notify_transmit_ready_cancel (p1.nth);
129 p1.nth = NULL;
130 }
131 if (connect_task != NULL)
132 { 164 {
133 GNUNET_SCHEDULER_cancel (connect_task); 165 GNUNET_SCHEDULER_cancel (connect_task);
134 connect_task = NULL; 166 connect_task = NULL;
135 } 167 }
136 ch = p1.ch;
137 p1.ch = NULL;
138 GNUNET_CORE_disconnect (ch);
139 ch = p2.ch;
140 p2.ch = NULL;
141 GNUNET_CORE_disconnect (ch);
142 GNUNET_TRANSPORT_disconnect (p1.th);
143 p1.th = NULL;
144 GNUNET_TRANSPORT_disconnect (p2.th);
145 p2.th = NULL;
146 GNUNET_free_non_null (p1.hello);
147 GNUNET_free_non_null (p2.hello);
148} 168}
149 169
150 170
151static void 171static void
152terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 172terminate_task_error (void *cls,
173 const struct GNUNET_SCHEDULER_TaskContext *tc)
153{ 174{
154 err_task = NULL; 175 err_task = NULL;
155 176
156 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 177 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase failed!\n"); 178 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
179 "Testcase failed!\n");
180 terminate_peer (&p1);
181 terminate_peer (&p2);
158 //GNUNET_break (0); 182 //GNUNET_break (0);
159 if (p1.nth != NULL) 183 if (NULL != measure_task)
160 { 184 {
161 GNUNET_CORE_notify_transmit_ready_cancel (p1.nth);
162 p1.nth = NULL;
163 }
164 if (measure_task != NULL)
165 GNUNET_SCHEDULER_cancel (measure_task); 185 GNUNET_SCHEDULER_cancel (measure_task);
166 if (connect_task != NULL) 186 measure_task = NULL;
187 }
188 if (NULL != connect_task)
167 { 189 {
168 GNUNET_SCHEDULER_cancel (connect_task); 190 GNUNET_SCHEDULER_cancel (connect_task);
169 connect_task = NULL; 191 connect_task = NULL;
170 } 192 }
171
172 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
173 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
174 if (NULL != p1.ch)
175 GNUNET_CORE_disconnect (p1.ch);
176 p1.ch = NULL;
177 if (NULL != p2.ch)
178 GNUNET_CORE_disconnect (p2.ch);
179 p2.ch = NULL;
180 if (NULL != p1.th)
181 GNUNET_TRANSPORT_disconnect (p1.th);
182 p1.th = NULL;
183 if (NULL != p2.th)
184 GNUNET_TRANSPORT_disconnect (p2.th);
185 p2.th = NULL;
186 ok = 42; 193 ok = 42;
187} 194}
188 195
189 196
190static void 197static void
191try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 198try_connect (void *cls,
199 const struct GNUNET_SCHEDULER_TaskContext *tc)
192{ 200{
193 connect_task = 201 connect_task =
194 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, 202 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
@@ -197,6 +205,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
197 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id, NULL, NULL); /*FIXME TRY_CONNECT change */ 205 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id, NULL, NULL); /*FIXME TRY_CONNECT change */
198} 206}
199 207
208
200/** 209/**
201 * Callback function to process statistic values. 210 * Callback function to process statistic values.
202 * 211 *
@@ -204,24 +213,33 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
204 * @param subsystem name of subsystem that created the statistic 213 * @param subsystem name of subsystem that created the statistic
205 * @param name the name of the datum 214 * @param name the name of the datum
206 * @param value the current value 215 * @param value the current value
207 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not 216 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
208 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 217 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
209 */ 218 */
210static int 219static int
211print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, 220print_stat (void *cls,
221 const char *subsystem,
222 const char *name,
223 uint64_t value,
212 int is_persistent) 224 int is_persistent)
213{ 225{
214 if (cls == &p1) 226 if (cls == &p1)
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer1 %50s = %12llu\n", name, 227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
228 "Peer1 %50s = %12llu\n",
229 name,
216 (unsigned long long) value); 230 (unsigned long long) value);
217 if (cls == &p2) 231 if (cls == &p2)
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer2 %50s = %12llu\n", name, 232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
233 "Peer2 %50s = %12llu\n",
234 name,
219 (unsigned long long) value); 235 (unsigned long long) value);
220 return GNUNET_OK; 236 return GNUNET_OK;
221} 237}
222 238
239
223static void 240static void
224measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 241measurement_stop (void *cls,
242 const struct GNUNET_SCHEDULER_TaskContext *tc)
225{ 243{
226 unsigned long long delta; 244 unsigned long long delta;
227 unsigned long long throughput_out; 245 unsigned long long throughput_out;
@@ -311,6 +329,7 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
311 329
312} 330}
313 331
332
314static size_t 333static size_t
315transmit_ready (void *cls, size_t size, void *buf) 334transmit_ready (void *cls, size_t size, void *buf)
316{ 335{
@@ -453,6 +472,7 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
453static size_t 472static size_t
454transmit_ready (void *cls, size_t size, void *buf); 473transmit_ready (void *cls, size_t size, void *buf);
455 474
475
456static int 476static int
457process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, 477process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
458 const struct GNUNET_MessageHeader *message) 478 const struct GNUNET_MessageHeader *message)
@@ -571,7 +591,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
571 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); 591 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
572 p->cfg = GNUNET_CONFIGURATION_create (); 592 p->cfg = GNUNET_CONFIGURATION_create ();
573 p->arm_proc = 593 p->arm_proc =
574 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 594 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
575 NULL, NULL, NULL, 595 NULL, NULL, NULL,
576 binary, 596 binary,
577 "gnunet-service-arm", 597 "gnunet-service-arm",
@@ -581,6 +601,8 @@ setup_peer (struct PeerContext *p, const char *cfgname)
581 GNUNET_assert (p->stats != NULL); 601 GNUNET_assert (p->stats != NULL);
582 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); 602 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
583 GNUNET_assert (p->th != NULL); 603 GNUNET_assert (p->th != NULL);
604 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
605 GNUNET_assert (NULL != p->ats);
584 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 606 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
585 GNUNET_free (binary); 607 GNUNET_free (binary);
586} 608}