diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-21 18:29:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-21 18:29:03 +0000 |
commit | 3d7b29ec1c5d1c2de96cf4c9badaa112e86ef899 (patch) | |
tree | b586e13615fe58377cef5c0a238a677e5fd8f609 /src/datastore/gnunet-service-datastore.c | |
parent | 1732154b8c021e7ee0e34c28cf3b1a843454727a (diff) | |
download | gnunet-3d7b29ec1c5d1c2de96cf4c9badaa112e86ef899.tar.gz gnunet-3d7b29ec1c5d1c2de96cf4c9badaa112e86ef899.zip |
update statistics API to use new MQ API style, also get rid of timeout argument
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 64c3640ad..a67d1c772 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -54,6 +54,11 @@ | |||
54 | static char *quota_stat_name; | 54 | static char *quota_stat_name; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Task to timeout stat GET. | ||
58 | */ | ||
59 | static struct GNUNET_SCHEDULER_Task *stat_timeout_task; | ||
60 | |||
61 | /** | ||
57 | * After how many payload-changing operations | 62 | * After how many payload-changing operations |
58 | * do we sync our statistics? | 63 | * do we sync our statistics? |
59 | */ | 64 | */ |
@@ -1526,8 +1531,12 @@ static void | |||
1526 | process_stat_done (void *cls, | 1531 | process_stat_done (void *cls, |
1527 | int success) | 1532 | int success) |
1528 | { | 1533 | { |
1529 | |||
1530 | stat_get = NULL; | 1534 | stat_get = NULL; |
1535 | if (NULL != stat_timeout_task) | ||
1536 | { | ||
1537 | GNUNET_SCHEDULER_cancel (stat_timeout_task); | ||
1538 | stat_timeout_task = NULL; | ||
1539 | } | ||
1531 | plugin = load_plugin (); | 1540 | plugin = load_plugin (); |
1532 | if (NULL == plugin) | 1541 | if (NULL == plugin) |
1533 | { | 1542 | { |
@@ -1576,6 +1585,20 @@ process_stat_done (void *cls, | |||
1576 | 1585 | ||
1577 | 1586 | ||
1578 | /** | 1587 | /** |
1588 | * Fetching stats took to long, run without. | ||
1589 | * | ||
1590 | * @param cls NULL | ||
1591 | */ | ||
1592 | static void | ||
1593 | stat_timeout (void *cls) | ||
1594 | { | ||
1595 | stat_timeout_task = NULL; | ||
1596 | GNUNET_STATISTICS_get_cancel (stat_get); | ||
1597 | process_stat_done (NULL, GNUNET_NO); | ||
1598 | } | ||
1599 | |||
1600 | |||
1601 | /** | ||
1579 | * Task run during shutdown. | 1602 | * Task run during shutdown. |
1580 | */ | 1603 | */ |
1581 | static void | 1604 | static void |
@@ -1617,6 +1640,11 @@ cleaning_task (void *cls) | |||
1617 | GNUNET_STATISTICS_get_cancel (stat_get); | 1640 | GNUNET_STATISTICS_get_cancel (stat_get); |
1618 | stat_get = NULL; | 1641 | stat_get = NULL; |
1619 | } | 1642 | } |
1643 | if (NULL != stat_timeout_task) | ||
1644 | { | ||
1645 | GNUNET_SCHEDULER_cancel (stat_timeout_task); | ||
1646 | stat_timeout_task = NULL; | ||
1647 | } | ||
1620 | GNUNET_free_non_null (plugin_name); | 1648 | GNUNET_free_non_null (plugin_name); |
1621 | plugin_name = NULL; | 1649 | plugin_name = NULL; |
1622 | if (last_sync > 0) | 1650 | if (last_sync > 0) |
@@ -1813,12 +1841,15 @@ run (void *cls, | |||
1813 | GNUNET_STATISTICS_get (stats, | 1841 | GNUNET_STATISTICS_get (stats, |
1814 | "datastore", | 1842 | "datastore", |
1815 | quota_stat_name, | 1843 | quota_stat_name, |
1816 | GNUNET_TIME_UNIT_SECONDS, | ||
1817 | &process_stat_done, | 1844 | &process_stat_done, |
1818 | &process_stat_in, | 1845 | &process_stat_in, |
1819 | NULL); | 1846 | NULL); |
1820 | if (NULL == stat_get) | 1847 | if (NULL == stat_get) |
1821 | process_stat_done (NULL, GNUNET_SYSERR); | 1848 | process_stat_done (NULL, GNUNET_SYSERR); |
1849 | else | ||
1850 | stat_timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
1851 | &stat_timeout, | ||
1852 | NULL); | ||
1822 | GNUNET_SERVER_disconnect_notify (server, | 1853 | GNUNET_SERVER_disconnect_notify (server, |
1823 | &cleanup_reservations, | 1854 | &cleanup_reservations, |
1824 | NULL); | 1855 | NULL); |