aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_quota_compliance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-11-16 11:51:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-11-16 11:51:20 +0000
commit7f082ef1cd69b48984b05ae72f3c124493fdd86e (patch)
treea9661c77a5e9e008fac7c3e949ee4af9a7fff2c6 /src/core/test_core_quota_compliance.c
parentc8b04f6520be4826220d74a2cecb688e6a6d73ba (diff)
downloadgnunet-7f082ef1cd69b48984b05ae72f3c124493fdd86e.tar.gz
gnunet-7f082ef1cd69b48984b05ae72f3c124493fdd86e.zip
Basic problem fixed:
Line 477: Timeout for GNUNET_CORE_peer_request_connect with 1 sec. too short to connect to other peer
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r--src/core/test_core_quota_compliance.c180
1 files changed, 96 insertions, 84 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index 88a735736..2fbe8dcc5 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -39,7 +39,7 @@
39#define VERBOSE GNUNET_YES 39#define VERBOSE GNUNET_YES
40 40
41#define START_ARM GNUNET_YES 41#define START_ARM GNUNET_YES
42#define DEBUG_CONNECTIONS GNUNET_NO 42#define DEBUG_CONNECTIONS GNUNET_YES
43 43
44/** 44/**
45 * Note that this value must not significantly exceed 45 * Note that this value must not significantly exceed
@@ -157,63 +157,6 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
157 ok = 42; 157 ok = 42;
158} 158}
159 159
160static void connect_notify (void *cls,
161 const struct GNUNET_PeerIdentity *peer,
162 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
163{
164 struct PeerContext *pc = cls;
165 GNUNET_assert (pc->connect_status == 0);
166 pc->connect_status = 1;
167#if DEBUG_CONNECTIONS
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
169 "Encrypted connection established to peer `%4s'\n",
170 GNUNET_i2s (peer));
171#endif
172}
173
174
175static void
176disconnect_notify (void *cls,
177 const struct GNUNET_PeerIdentity *peer)
178{
179 struct PeerContext *pc = cls;
180 pc->connect_status = 0;
181#if DEBUG_CONNECTIONS
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
183 "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
184#endif
185}
186
187
188static int
189inbound_notify (void *cls,
190 const struct GNUNET_PeerIdentity *other,
191 const struct GNUNET_MessageHeader *message,
192 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
193{
194 total_bytes_recv += ntohs (message->size);
195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
196 "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s (other), ntohs (message->size));
197#if DEBUG_CONNECTIONS
198 #endif
199 return GNUNET_OK;
200}
201
202
203static int
204outbound_notify (void *cls,
205 const struct GNUNET_PeerIdentity *other,
206 const struct GNUNET_MessageHeader *message,
207 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
208{
209#if DEBUG_CONNECTIONS
210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
211 "Core notifies about outbound data for `%4s'.\n",
212 GNUNET_i2s (other));
213#endif
214 return GNUNET_OK;
215}
216
217static void 160static void
218next_fin (void *cls, int success) 161next_fin (void *cls, int success)
219{ 162{
@@ -230,26 +173,43 @@ check_2 (void *cls,
230 return GNUNET_OK; 173 return GNUNET_OK;
231} 174}
232 175
176static size_t
177transmit_ready (void *cls, size_t size, void *buf);
178
179static void
180send_tsk (void *cls,
181 const struct GNUNET_SCHEDULER_TaskContext *tc)
182{
183 send_task = GNUNET_SCHEDULER_NO_TASK;
184
185 ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
186 0,
187 FAST_TIMEOUT,
188 &p2.id,
189 sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE,
190 &transmit_ready, &p1);
191}
192
233static void 193static void
234measurement_end (void *cls, 194measurement_end (void *cls,
235 const struct GNUNET_SCHEDULER_TaskContext *tc) 195 const struct GNUNET_SCHEDULER_TaskContext *tc)
236{ 196{
237 struct GNUNET_TIME_Relative duration; 197 struct GNUNET_TIME_Relative duration;
238 198
239 measure_task = GNUNET_SCHEDULER_NO_TASK; 199 measure_task = GNUNET_SCHEDULER_NO_TASK;
240 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 200 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
241 return; 201 return;
242 202
243 if (err_task != GNUNET_SCHEDULER_NO_TASK) 203 if (err_task != GNUNET_SCHEDULER_NO_TASK)
244 GNUNET_SCHEDULER_cancel (err_task); 204 GNUNET_SCHEDULER_cancel (err_task);
245 if (send_task != GNUNET_SCHEDULER_NO_TASK) 205 if (send_task != GNUNET_SCHEDULER_NO_TASK)
246 GNUNET_SCHEDULER_cancel (send_task); 206 GNUNET_SCHEDULER_cancel (send_task);
247 207
248 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 208 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
249 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); 209 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
250 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 210 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
251 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); 211 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
252 212
253 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 213 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
254 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); 214 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
255 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 215 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
@@ -267,25 +227,8 @@ measurement_end (void *cls,
267 GNUNET_SCHEDULER_add_now (&terminate_task, NULL); 227 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
268} 228}
269 229
270static size_t
271transmit_ready (void *cls, size_t size, void *buf);
272 230
273static void 231static void
274send_tsk (void *cls,
275 const struct GNUNET_SCHEDULER_TaskContext *tc)
276{
277 send_task = GNUNET_SCHEDULER_NO_TASK;
278
279 ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
280 0,
281 FAST_TIMEOUT,
282 &p2.id,
283 sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE,
284 &transmit_ready, &p1);
285}
286
287
288static void
289measure (unsigned long long quota_p1, unsigned long long quota_p2) 232measure (unsigned long long quota_p1, unsigned long long quota_p2)
290{ 233{
291#if VERBOSE 234#if VERBOSE
@@ -320,6 +263,70 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2)
320 &transmit_ready, &p1); 263 &transmit_ready, &p1);
321} 264}
322 265
266static void connect_notify (void *cls,
267 const struct GNUNET_PeerIdentity *peer,
268 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
269{
270 struct PeerContext *pc = cls;
271
272 GNUNET_assert (pc->connect_status == 0);
273 pc->connect_status = 1;
274 if (pc == &p1)
275 {
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
277 "Encrypted connection established to peer `%4s'\n",
278 GNUNET_i2s (peer));
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
280 "Asking core (1) for transmission to peer `%4s'\n",
281 GNUNET_i2s (&p2.id));
282 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
283 }
284}
285
286
287static void
288disconnect_notify (void *cls,
289 const struct GNUNET_PeerIdentity *peer)
290{
291 struct PeerContext *pc = cls;
292 pc->connect_status = 0;
293#if DEBUG_CONNECTIONS
294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
295 "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
296#endif
297}
298
299
300static int
301inbound_notify (void *cls,
302 const struct GNUNET_PeerIdentity *other,
303 const struct GNUNET_MessageHeader *message,
304 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
305{
306 total_bytes_recv += ntohs (message->size);
307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
308 "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s (other), ntohs (message->size));
309#if DEBUG_CONNECTIONS
310 #endif
311 return GNUNET_OK;
312}
313
314
315static int
316outbound_notify (void *cls,
317 const struct GNUNET_PeerIdentity *other,
318 const struct GNUNET_MessageHeader *message,
319 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
320{
321#if DEBUG_CONNECTIONS
322 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
323 "Core notifies about outbound data for `%4s'.\n",
324 GNUNET_i2s (other));
325#endif
326 return GNUNET_OK;
327}
328
329
323static int tr_n; 330static int tr_n;
324 331
325 332
@@ -369,7 +376,7 @@ transmit_ready (void *cls, size_t size, void *buf)
369 if (measurement_running != GNUNET_YES) 376 if (measurement_running != GNUNET_YES)
370 return 0; 377 return 0;
371 378
372 GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); 379 GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
373 if (buf == NULL) 380 if (buf == NULL)
374 { 381 {
375 if (p1.ch != NULL) 382 if (p1.ch != NULL)
@@ -414,7 +421,7 @@ transmit_ready (void *cls, size_t size, void *buf)
414 while (size - ret >= s); 421 while (size - ret >= s);
415 GNUNET_SCHEDULER_cancel (err_task); 422 GNUNET_SCHEDULER_cancel (err_task);
416 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 423 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
417 &terminate_task_error, 424 &terminate_task_error,
418 NULL); 425 NULL);
419 426
420 total_bytes += ret; 427 total_bytes += ret;
@@ -453,7 +460,7 @@ init_notify (void *cls,
453 &init_notify, 460 &init_notify,
454 &connect_notify, 461 &connect_notify,
455 &disconnect_notify, 462 &disconnect_notify,
456 NULL, 463 NULL,
457 &inbound_notify, 464 &inbound_notify,
458 GNUNET_YES, 465 GNUNET_YES,
459 &outbound_notify, GNUNET_YES, handlers); 466 &outbound_notify, GNUNET_YES, handlers);
@@ -463,8 +470,13 @@ init_notify (void *cls,
463 GNUNET_assert (ok == 3); 470 GNUNET_assert (ok == 3);
464 OKPP; 471 OKPP;
465 GNUNET_assert (cls == &p2); 472 GNUNET_assert (cls == &p2);
466 473 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
467 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA); 474 "Asking core (1) to connect to peer `%4s'\n",
475 GNUNET_i2s (&p2.id));
476 GNUNET_CORE_peer_request_connect (p1.ch,
477 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
478 &p2.id,
479 NULL, NULL);
468 } 480 }
469} 481}
470 482