aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-21 18:29:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-21 18:29:03 +0000
commit3d7b29ec1c5d1c2de96cf4c9badaa112e86ef899 (patch)
treeb586e13615fe58377cef5c0a238a677e5fd8f609 /src/datastore
parent1732154b8c021e7ee0e34c28cf3b1a843454727a (diff)
update statistics API to use new MQ API style, also get rid of timeout argument
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/gnunet-service-datastore.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 64c3640ad8..a67d1c7725 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -54,6 +54,11 @@
static char *quota_stat_name;
/**
+ * Task to timeout stat GET.
+ */
+static struct GNUNET_SCHEDULER_Task *stat_timeout_task;
+
+/**
* After how many payload-changing operations
* do we sync our statistics?
*/
@@ -1526,8 +1531,12 @@ static void
process_stat_done (void *cls,
int success)
{
-
stat_get = NULL;
+ if (NULL != stat_timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel (stat_timeout_task);
+ stat_timeout_task = NULL;
+ }
plugin = load_plugin ();
if (NULL == plugin)
{
@@ -1576,6 +1585,20 @@ process_stat_done (void *cls,
/**
+ * Fetching stats took to long, run without.
+ *
+ * @param cls NULL
+ */
+static void
+stat_timeout (void *cls)
+{
+ stat_timeout_task = NULL;
+ GNUNET_STATISTICS_get_cancel (stat_get);
+ process_stat_done (NULL, GNUNET_NO);
+}
+
+
+/**
* Task run during shutdown.
*/
static void
@@ -1617,6 +1640,11 @@ cleaning_task (void *cls)
GNUNET_STATISTICS_get_cancel (stat_get);
stat_get = NULL;
}
+ if (NULL != stat_timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel (stat_timeout_task);
+ stat_timeout_task = NULL;
+ }
GNUNET_free_non_null (plugin_name);
plugin_name = NULL;
if (last_sync > 0)
@@ -1813,12 +1841,15 @@ run (void *cls,
GNUNET_STATISTICS_get (stats,
"datastore",
quota_stat_name,
- GNUNET_TIME_UNIT_SECONDS,
&process_stat_done,
&process_stat_in,
NULL);
if (NULL == stat_get)
process_stat_done (NULL, GNUNET_SYSERR);
+ else
+ stat_timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &stat_timeout,
+ NULL);
GNUNET_SERVER_disconnect_notify (server,
&cleanup_reservations,
NULL);