diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-19 14:53:27 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-19 14:53:27 +0000 |
commit | f78df915ad04751636a01a4a34ab36eb65209845 (patch) | |
tree | 087c9aac30afdf889781f106669cae149c133f80 /src/ats | |
parent | c0abb843581bdf5234b33d03d29351269eb8a3d0 (diff) | |
download | gnunet-f78df915ad04751636a01a4a34ab36eb65209845.tar.gz gnunet-f78df915ad04751636a01a4a34ab36eb65209845.zip |
changes
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 11 | ||||
-rw-r--r-- | src/ats/test_ats_api_performance_monitor.c | 41 |
2 files changed, 43 insertions, 9 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index b757ede62..e82613471 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -531,6 +531,7 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
531 | { | 531 | { |
532 | struct PerformanceClient *cur; | 532 | struct PerformanceClient *cur; |
533 | struct PerformanceMonitorClient *curm; | 533 | struct PerformanceMonitorClient *curm; |
534 | struct MonitorResponseMessage *mrm; | ||
534 | for (cur = pc_head; NULL != cur; cur = cur->next) | 535 | for (cur = pc_head; NULL != cur; cur = cur->next) |
535 | for (curm = cur->pm_head; NULL != curm; curm = curm->next) | 536 | for (curm = cur->pm_head; NULL != curm; curm = curm->next) |
536 | { | 537 | { |
@@ -561,7 +562,10 @@ GAS_handle_monitor (void *cls, | |||
561 | 562 | ||
562 | msg_size = ntohs (message->size); | 563 | msg_size = ntohs (message->size); |
563 | if (msg_size < sizeof (struct MonitorMessage)) | 564 | if (msg_size < sizeof (struct MonitorMessage)) |
564 | return; | 565 | { |
566 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
567 | return; | ||
568 | } | ||
565 | 569 | ||
566 | id = ntohl (mm->id); | 570 | id = ntohl (mm->id); |
567 | op = ntohl (mm->op); | 571 | op = ntohl (mm->op); |
@@ -576,6 +580,7 @@ GAS_handle_monitor (void *cls, | |||
576 | if (NULL != res) | 580 | if (NULL != res) |
577 | { | 581 | { |
578 | GNUNET_break (0); | 582 | GNUNET_break (0); |
583 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
579 | return; /* Duplicate*/ | 584 | return; /* Duplicate*/ |
580 | } | 585 | } |
581 | res = GNUNET_malloc (sizeof (struct PerformanceMonitorClient)); | 586 | res = GNUNET_malloc (sizeof (struct PerformanceMonitorClient)); |
@@ -592,6 +597,7 @@ GAS_handle_monitor (void *cls, | |||
592 | if (NULL == res) | 597 | if (NULL == res) |
593 | { | 598 | { |
594 | GNUNET_break (0); | 599 | GNUNET_break (0); |
600 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
595 | return; /* Not existing */ | 601 | return; /* Not existing */ |
596 | } | 602 | } |
597 | GNUNET_CONTAINER_DLL_remove (pc->pm_head, pc->pm_tail, res); | 603 | GNUNET_CONTAINER_DLL_remove (pc->pm_head, pc->pm_tail, res); |
@@ -603,9 +609,10 @@ GAS_handle_monitor (void *cls, | |||
603 | else | 609 | else |
604 | { | 610 | { |
605 | GNUNET_break (0); | 611 | GNUNET_break (0); |
612 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
606 | return; | 613 | return; |
607 | } | 614 | } |
608 | 615 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | |
609 | } | 616 | } |
610 | 617 | ||
611 | 618 | ||
diff --git a/src/ats/test_ats_api_performance_monitor.c b/src/ats/test_ats_api_performance_monitor.c index eebe23749..e89b46b04 100644 --- a/src/ats/test_ats_api_performance_monitor.c +++ b/src/ats/test_ats_api_performance_monitor.c | |||
@@ -28,10 +28,11 @@ | |||
28 | #include "gnunet_testing_lib.h" | 28 | #include "gnunet_testing_lib.h" |
29 | #include "ats.h" | 29 | #include "ats.h" |
30 | 30 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) |
32 | 32 | #define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | |
33 | 33 | ||
34 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 34 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
35 | static GNUNET_SCHEDULER_TaskIdentifier stage_task; | ||
35 | 36 | ||
36 | struct GNUNET_CONFIGURATION_Handle *cfg; | 37 | struct GNUNET_CONFIGURATION_Handle *cfg; |
37 | 38 | ||
@@ -45,6 +46,11 @@ static int ret; | |||
45 | static void | 46 | static void |
46 | end_now (int res) | 47 | end_now (int res) |
47 | { | 48 | { |
49 | if (GNUNET_SCHEDULER_NO_TASK != stage_task) | ||
50 | { | ||
51 | GNUNET_SCHEDULER_cancel (stage_task); | ||
52 | stage_task = GNUNET_SCHEDULER_NO_TASK; | ||
53 | } | ||
48 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 54 | if (GNUNET_SCHEDULER_NO_TASK != die_task) |
49 | { | 55 | { |
50 | GNUNET_SCHEDULER_cancel (die_task); | 56 | GNUNET_SCHEDULER_cancel (die_task); |
@@ -73,6 +79,31 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
73 | end_now (1); | 79 | end_now (1); |
74 | } | 80 | } |
75 | 81 | ||
82 | static void | ||
83 | next_stage (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
84 | { | ||
85 | static int stage_counter = 0; | ||
86 | |||
87 | stage_task = GNUNET_SCHEDULER_NO_TASK; | ||
88 | if (0 == stage_counter) | ||
89 | { | ||
90 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stop performance monitoring\n"); | ||
91 | |||
92 | GNUNET_ATS_performance_monitor_stop (phm); | ||
93 | phm = NULL; | ||
94 | |||
95 | stage_task = GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next_stage, NULL); | ||
96 | stage_counter++; | ||
97 | return; | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | end_now (0); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | |||
106 | |||
76 | 107 | ||
77 | static void | 108 | static void |
78 | perf_mon_cb (void *cls, | 109 | perf_mon_cb (void *cls, |
@@ -99,11 +130,7 @@ run (void *cls, | |||
99 | phm = GNUNET_ATS_performance_monitor_start (ph, &perf_mon_cb, &ret); | 130 | phm = GNUNET_ATS_performance_monitor_start (ph, &perf_mon_cb, &ret); |
100 | GNUNET_assert (NULL != phm); | 131 | GNUNET_assert (NULL != phm); |
101 | 132 | ||
102 | // GNUNET_ATS_performance_monitor_stop (phm); | 133 | stage_task = GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next_stage, NULL); |
103 | |||
104 | //GNUNET_ATS_performance_done (ph); | ||
105 | // ph = NULL; | ||
106 | //end_now (0); | ||
107 | } | 134 | } |
108 | 135 | ||
109 | 136 | ||