aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/statistics_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/statistics_api.c')
-rw-r--r--src/statistics/statistics_api.c51
1 files changed, 50 insertions, 1 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);