diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/core/test_core_quota_compliance.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r-- | src/core/test_core_quota_compliance.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index d69fb0905..822dc2c46 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -105,8 +105,6 @@ static struct PeerContext p1; | |||
105 | 105 | ||
106 | static struct PeerContext p2; | 106 | static struct PeerContext p2; |
107 | 107 | ||
108 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
109 | |||
110 | static int ok; | 108 | static int ok; |
111 | static int measurement_running; | 109 | static int measurement_running; |
112 | 110 | ||
@@ -147,7 +145,7 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
147 | { | 145 | { |
148 | GNUNET_break (0); | 146 | GNUNET_break (0); |
149 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 147 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
150 | GNUNET_SCHEDULER_cancel (sched,send_task); | 148 | GNUNET_SCHEDULER_cancel (send_task); |
151 | GNUNET_CORE_disconnect (p1.ch); | 149 | GNUNET_CORE_disconnect (p1.ch); |
152 | p1.ch = NULL; | 150 | p1.ch = NULL; |
153 | GNUNET_CORE_disconnect (p2.ch); | 151 | GNUNET_CORE_disconnect (p2.ch); |
@@ -247,9 +245,9 @@ measurement_end (void *cls, | |||
247 | return; | 245 | return; |
248 | 246 | ||
249 | if (err_task != GNUNET_SCHEDULER_NO_TASK) | 247 | if (err_task != GNUNET_SCHEDULER_NO_TASK) |
250 | GNUNET_SCHEDULER_cancel (sched, err_task); | 248 | GNUNET_SCHEDULER_cancel (err_task); |
251 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 249 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
252 | GNUNET_SCHEDULER_cancel (sched,send_task); | 250 | GNUNET_SCHEDULER_cancel (send_task); |
253 | 251 | ||
254 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); | 252 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); |
255 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); | 253 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); |
@@ -271,7 +269,7 @@ measurement_end (void *cls, | |||
271 | (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); | 269 | (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); |
272 | 270 | ||
273 | 271 | ||
274 | GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); | 272 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
275 | } | 273 | } |
276 | 274 | ||
277 | static size_t | 275 | static size_t |
@@ -307,12 +305,10 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | |||
307 | "Asking core (1) for transmission to peer `%4s'\n", | 305 | "Asking core (1) for transmission to peer `%4s'\n", |
308 | GNUNET_i2s (&p2.id)); | 306 | GNUNET_i2s (&p2.id)); |
309 | #endif | 307 | #endif |
310 | err_task = GNUNET_SCHEDULER_add_delayed (sched, | 308 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
311 | TIMEOUT, | ||
312 | &terminate_task_error, | 309 | &terminate_task_error, |
313 | NULL); | 310 | NULL); |
314 | measure_task = GNUNET_SCHEDULER_add_delayed (sched, | 311 | measure_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, |
315 | MEASUREMENT_INTERVALL, | ||
316 | &measurement_end, | 312 | &measurement_end, |
317 | NULL); | 313 | NULL); |
318 | start_time = GNUNET_TIME_absolute_get (); | 314 | start_time = GNUNET_TIME_absolute_get (); |
@@ -420,17 +416,16 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
420 | break; /* sometimes pack buffer full, sometimes not */ | 416 | break; /* sometimes pack buffer full, sometimes not */ |
421 | } | 417 | } |
422 | while (size - ret >= s); | 418 | while (size - ret >= s); |
423 | GNUNET_SCHEDULER_cancel (sched, err_task); | 419 | GNUNET_SCHEDULER_cancel (err_task); |
424 | err_task = GNUNET_SCHEDULER_add_delayed (sched, | 420 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
425 | TIMEOUT, | ||
426 | &terminate_task_error, | 421 | &terminate_task_error, |
427 | NULL); | 422 | NULL); |
428 | 423 | ||
429 | total_bytes += ret; | 424 | total_bytes += ret; |
430 | total_bytes_sent += ret; | 425 | total_bytes_sent += ret; |
431 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 426 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
432 | GNUNET_SCHEDULER_cancel(sched, send_task); | 427 | GNUNET_SCHEDULER_cancel(send_task); |
433 | send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); | 428 | send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); |
434 | 429 | ||
435 | return ret; | 430 | return ret; |
436 | } | 431 | } |
@@ -457,8 +452,7 @@ init_notify (void *cls, | |||
457 | GNUNET_assert (ok == 2); | 452 | GNUNET_assert (ok == 2); |
458 | OKPP; | 453 | OKPP; |
459 | /* connect p2 */ | 454 | /* connect p2 */ |
460 | GNUNET_CORE_connect (sched, | 455 | GNUNET_CORE_connect (p2.cfg, |
461 | p2.cfg, | ||
462 | TIMEOUT, | 456 | TIMEOUT, |
463 | &p2, | 457 | &p2, |
464 | &init_notify, | 458 | &init_notify, |
@@ -521,9 +515,9 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
521 | "-c", cfgname, NULL); | 515 | "-c", cfgname, NULL); |
522 | #endif | 516 | #endif |
523 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 517 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
524 | p->stats = GNUNET_STATISTICS_create (sched, "core", p->cfg); | 518 | p->stats = GNUNET_STATISTICS_create ("core", p->cfg); |
525 | GNUNET_assert (p->stats != NULL); | 519 | GNUNET_assert (p->stats != NULL); |
526 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); | 520 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); |
527 | GNUNET_assert (p->th != NULL); | 521 | GNUNET_assert (p->th != NULL); |
528 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 522 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
529 | } | 523 | } |
@@ -531,18 +525,15 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
531 | 525 | ||
532 | static void | 526 | static void |
533 | run (void *cls, | 527 | run (void *cls, |
534 | struct GNUNET_SCHEDULER_Handle *s, | ||
535 | char *const *args, | 528 | char *const *args, |
536 | const char *cfgfile, | 529 | const char *cfgfile, |
537 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 530 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
538 | { | 531 | { |
539 | GNUNET_assert (ok == 1); | 532 | GNUNET_assert (ok == 1); |
540 | OKPP; | 533 | OKPP; |
541 | sched = s; | ||
542 | setup_peer (&p1, "test_core_quota_peer1.conf"); | 534 | setup_peer (&p1, "test_core_quota_peer1.conf"); |
543 | setup_peer (&p2, "test_core_quota_peer2.conf"); | 535 | setup_peer (&p2, "test_core_quota_peer2.conf"); |
544 | GNUNET_CORE_connect (sched, | 536 | GNUNET_CORE_connect (p1.cfg, |
545 | p1.cfg, | ||
546 | TIMEOUT, | 537 | TIMEOUT, |
547 | &p1, | 538 | &p1, |
548 | &init_notify, | 539 | &init_notify, |