aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_quota_compliance.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/core/test_core_quota_compliance.c
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r--src/core/test_core_quota_compliance.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index be875c235..856ed13fd 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -185,8 +185,9 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
185static void 185static void
186try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 186try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
187{ 187{
188 connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 188 connect_task =
189 &try_connect, NULL); 189 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
190 NULL);
190 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 191 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
191 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); 192 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
192} 193}
@@ -231,13 +232,11 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
231 232
232 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 233 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
233 234
234 throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */ 235 throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */
235 throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */ 236 throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */
236 237
237 max_quota_in = GNUNET_MIN (current_quota_p1_in, 238 max_quota_in = GNUNET_MIN (current_quota_p1_in, current_quota_p2_in);
238 current_quota_p2_in); 239 max_quota_out = GNUNET_MIN (current_quota_p1_out, current_quota_p2_out);
239 max_quota_out = GNUNET_MIN (current_quota_p1_out,
240 current_quota_p2_out);
241 if (max_quota_out < max_quota_in) 240 if (max_quota_out < max_quota_in)
242 quota_delta = max_quota_in / 5; 241 quota_delta = max_quota_in / 5;
243 else 242 else
@@ -274,7 +273,7 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
274 GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); 273 GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2);
275 274
276 if (ok != 0) 275 if (ok != 0)
277 kind = GNUNET_ERROR_TYPE_ERROR; 276 kind = GNUNET_ERROR_TYPE_ERROR;
278 switch (test) 277 switch (test)
279 { 278 {
280 case SYMMETRIC: 279 case SYMMETRIC:
@@ -294,12 +293,10 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
294 }; 293 };
295 GNUNET_log (kind, "Peer 1 send rate: %llu b/s (%llu bytes in %llu ms)\n", 294 GNUNET_log (kind, "Peer 1 send rate: %llu b/s (%llu bytes in %llu ms)\n",
296 throughput_out, total_bytes_sent, delta); 295 throughput_out, total_bytes_sent, delta);
297 GNUNET_log (kind, "Peer 1 send quota: %llu b/s\n", 296 GNUNET_log (kind, "Peer 1 send quota: %llu b/s\n", current_quota_p1_out);
298 current_quota_p1_out);
299 GNUNET_log (kind, "Peer 2 receive rate: %llu b/s (%llu bytes in %llu ms)\n", 297 GNUNET_log (kind, "Peer 2 receive rate: %llu b/s (%llu bytes in %llu ms)\n",
300 throughput_in, total_bytes_recv, delta); 298 throughput_in, total_bytes_recv, delta);
301 GNUNET_log (kind, "Peer 2 receive quota: %llu b/s\n", 299 GNUNET_log (kind, "Peer 2 receive quota: %llu b/s\n", current_quota_p2_in);
302 current_quota_p2_in);
303/* 300/*
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu b/s\n",max_quota_in ); 301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu b/s\n",max_quota_in );
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu b/s\n",max_quota_out); 302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu b/s\n",max_quota_out);
@@ -322,10 +319,11 @@ transmit_ready (void *cls, size_t size, void *buf)
322 { 319 {
323 if ((p1.ch != NULL) && (p1.connect_status == 1)) 320 if ((p1.ch != NULL) && (p1.connect_status == 1))
324 GNUNET_break (NULL != 321 GNUNET_break (NULL !=
325 (p1.nth = GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, 322 (p1.nth =
326 FAST_TIMEOUT, &p2.id, 323 GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
327 MESSAGESIZE, 324 FAST_TIMEOUT, &p2.id,
328 &transmit_ready, &p1))); 325 MESSAGESIZE,
326 &transmit_ready, &p1)));
329 return 0; 327 return 0;
330 } 328 }
331 GNUNET_assert (tr_n < TOTAL_MSGS); 329 GNUNET_assert (tr_n < TOTAL_MSGS);
@@ -364,12 +362,13 @@ transmit_ready (void *cls, size_t size, void *buf)
364 362
365static void 363static void
366connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, 364connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
367 const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) 365 const struct GNUNET_ATS_Information *atsi,
366 unsigned int atsi_count)
368{ 367{
369 struct PeerContext *pc = cls; 368 struct PeerContext *pc = cls;
370 369
371 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) 370 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity)))
372 return; /* loopback */ 371 return; /* loopback */
373 GNUNET_assert (pc->connect_status == 0); 372 GNUNET_assert (pc->connect_status == 0);
374 pc->connect_status = 1; 373 pc->connect_status = 1;
375 if (pc == &p1) 374 if (pc == &p1)
@@ -393,10 +392,11 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
393 NULL); 392 NULL);
394 393
395 GNUNET_break (NULL != 394 GNUNET_break (NULL !=
396 (p1.nth = GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, 395 (p1.nth =
397 TIMEOUT, &p2.id, 396 GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
398 MESSAGESIZE, 397 TIMEOUT, &p2.id,
399 &transmit_ready, &p1))); 398 MESSAGESIZE,
399 &transmit_ready, &p1)));
400 } 400 }
401} 401}
402 402
@@ -407,12 +407,12 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
407 struct PeerContext *pc = cls; 407 struct PeerContext *pc = cls;
408 408
409 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) 409 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity)))
410 return; /* loopback */ 410 return; /* loopback */
411 pc->connect_status = 0; 411 pc->connect_status = 0;
412 if (GNUNET_SCHEDULER_NO_TASK != measure_task) 412 if (GNUNET_SCHEDULER_NO_TASK != measure_task)
413 { 413 {
414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
415 "Measurement aborted due to disconnect!\n"); 415 "Measurement aborted due to disconnect!\n");
416 GNUNET_SCHEDULER_cancel (measure_task); 416 GNUNET_SCHEDULER_cancel (measure_task);
417 measure_task = GNUNET_SCHEDULER_NO_TASK; 417 measure_task = GNUNET_SCHEDULER_NO_TASK;
418 } 418 }
@@ -431,7 +431,8 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
431static int 431static int
432inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, 432inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
433 const struct GNUNET_MessageHeader *message, 433 const struct GNUNET_MessageHeader *message,
434 const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) 434 const struct GNUNET_ATS_Information *atsi,
435 unsigned int atsi_count)
435{ 436{
436#if DEBUG_TRANSMISSION 437#if DEBUG_TRANSMISSION
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -446,7 +447,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
446static int 447static int
447outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, 448outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
448 const struct GNUNET_MessageHeader *message, 449 const struct GNUNET_MessageHeader *message,
449 const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) 450 const struct GNUNET_ATS_Information *atsi,
451 unsigned int atsi_count)
450{ 452{
451#if DEBUG_TRANSMISSION 453#if DEBUG_TRANSMISSION
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -463,7 +465,8 @@ transmit_ready (void *cls, size_t size, void *buf);
463static int 465static int
464process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, 466process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
465 const struct GNUNET_MessageHeader *message, 467 const struct GNUNET_MessageHeader *message,
466 const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) 468 const struct GNUNET_ATS_Information *atsi,
469 unsigned int atsi_count)
467{ 470{
468 static int n; 471 static int n;
469 const struct TestMessage *hdr; 472 const struct TestMessage *hdr;
@@ -532,9 +535,10 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
532 GNUNET_assert (ok == 2); 535 GNUNET_assert (ok == 2);
533 OKPP; 536 OKPP;
534 /* connect p2 */ 537 /* connect p2 */
535 p2.ch = GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, 538 p2.ch =
536 &disconnect_notify, &inbound_notify, GNUNET_YES, 539 GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
537 &outbound_notify, GNUNET_YES, handlers); 540 &disconnect_notify, &inbound_notify, GNUNET_YES,
541 &outbound_notify, GNUNET_YES, handlers);
538 } 542 }
539 else 543 else
540 { 544 {
@@ -546,8 +550,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
546 "Asking core (1) to connect to peer `%4s'\n", 550 "Asking core (1) to connect to peer `%4s'\n",
547 GNUNET_i2s (&p2.id)); 551 GNUNET_i2s (&p2.id));
548#endif 552#endif
549 connect_task = GNUNET_SCHEDULER_add_now (&try_connect, 553 connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
550 NULL);
551 } 554 }
552} 555}
553 556
@@ -642,9 +645,10 @@ run (void *cls, char *const *args, const char *cfgfile,
642 "TOTAL_QUOTA_OUT", 645 "TOTAL_QUOTA_OUT",
643 &current_quota_p2_out)); 646 &current_quota_p2_out));
644 647
645 p1.ch = GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, 648 p1.ch =
646 &disconnect_notify, &inbound_notify, GNUNET_YES, 649 GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
647 &outbound_notify, GNUNET_YES, handlers); 650 &disconnect_notify, &inbound_notify, GNUNET_YES,
651 &outbound_notify, GNUNET_YES, handlers);
648} 652}
649 653
650 654