diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-07-01 09:03:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-07-01 09:03:30 +0000 |
commit | c2c2321102d8b2ce8cd3cba888138a6be86e2b87 (patch) | |
tree | 2e8feaa5aa09e6ee6877f330eb6613315ff04c34 /src | |
parent | bb8008b30082fc8096c3f407dd2e2f3e42442f47 (diff) | |
download | gnunet-c2c2321102d8b2ce8cd3cba888138a6be86e2b87.tar.gz gnunet-c2c2321102d8b2ce8cd3cba888138a6be86e2b87.zip |
stats fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/statistics/statistics_api.c | 51 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_loop.c | 2 |
2 files changed, 51 insertions, 2 deletions
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 3289745b1..ed3d0bdb7 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -752,7 +752,8 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, | |||
752 | size_t slen; | 752 | size_t slen; |
753 | size_t nlen; | 753 | size_t nlen; |
754 | size_t nsize; | 754 | size_t nsize; |
755 | 755 | int64_t delta; | |
756 | |||
756 | GNUNET_assert (h != NULL); | 757 | GNUNET_assert (h != NULL); |
757 | GNUNET_assert (name != NULL); | 758 | GNUNET_assert (name != NULL); |
758 | if (GNUNET_YES != try_connect (h)) | 759 | if (GNUNET_YES != try_connect (h)) |
@@ -765,6 +766,54 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, | |||
765 | GNUNET_break (0); | 766 | GNUNET_break (0); |
766 | return; | 767 | return; |
767 | } | 768 | } |
769 | ai = h->action_head; | ||
770 | while (ai != NULL) | ||
771 | { | ||
772 | if ( (0 == strcmp (ai->subsystem, h->subsystem)) && | ||
773 | (0 == strcmp (ai->name, name)) && | ||
774 | ( (ai->type == ACTION_UPDATE) || | ||
775 | (ai->type == ACTION_SET) ) ) | ||
776 | { | ||
777 | if (ai->type == ACTION_SET) | ||
778 | { | ||
779 | if (type == ACTION_UPDATE) | ||
780 | { | ||
781 | delta = (int64_t) value; | ||
782 | if (delta > 0) | ||
783 | { | ||
784 | ai->value += delta; | ||
785 | } | ||
786 | else | ||
787 | { | ||
788 | if (ai->value < -delta) | ||
789 | ai->value = 0; | ||
790 | else | ||
791 | ai->value += delta; | ||
792 | } | ||
793 | } | ||
794 | else | ||
795 | { | ||
796 | ai->value = value; | ||
797 | } | ||
798 | } | ||
799 | else | ||
800 | { | ||
801 | if (type == ACTION_UPDATE) | ||
802 | { | ||
803 | delta = (int64_t) value; | ||
804 | ai->value += delta; | ||
805 | } | ||
806 | else | ||
807 | { | ||
808 | ai->value = value; | ||
809 | ai->type = type; | ||
810 | } | ||
811 | } | ||
812 | ai->timeout = GNUNET_TIME_relative_to_absolute (SET_TRANSMIT_TIMEOUT); | ||
813 | return; | ||
814 | } | ||
815 | ai = ai->next; | ||
816 | } | ||
768 | ai = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_GetHandle)); | 817 | ai = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_GetHandle)); |
769 | ai->sh = h; | 818 | ai->sh = h; |
770 | ai->subsystem = GNUNET_strdup (h->subsystem); | 819 | ai->subsystem = GNUNET_strdup (h->subsystem); |
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index b70e92bdc..5ba6132bf 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c | |||
@@ -79,7 +79,7 @@ run (void *cls, | |||
79 | i = 0; | 79 | i = 0; |
80 | GNUNET_break (NULL != | 80 | GNUNET_break (NULL != |
81 | GNUNET_STATISTICS_get (h, NULL, "test-0", | 81 | GNUNET_STATISTICS_get (h, NULL, "test-0", |
82 | GNUNET_TIME_UNIT_SECONDS, &next, &check_1, cls)); | 82 | GNUNET_TIME_UNIT_MINUTES, &next, &check_1, cls)); |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||