aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
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/hostlist
parent1732154b8c021e7ee0e34c28cf3b1a843454727a (diff)
downloadgnunet-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/hostlist')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c
index 15a82c2d5..df0cabe1d 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -1265,8 +1265,14 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
1265 * successfully obtained, #GNUNET_SYSERR if not. 1265 * successfully obtained, #GNUNET_SYSERR if not.
1266 */ 1266 */
1267static void 1267static void
1268primary_task (void *cls, int success) 1268primary_task (void *cls,
1269 int success)
1269{ 1270{
1271 if (NULL != ti_check_download)
1272 {
1273 GNUNET_SCHEDULER_cancel (ti_check_download);
1274 ti_check_download = NULL;
1275 }
1270 sget = NULL; 1276 sget = NULL;
1271 GNUNET_assert (NULL != stats); 1277 GNUNET_assert (NULL != stats);
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1276,6 +1282,24 @@ primary_task (void *cls, int success)
1276 1282
1277 1283
1278/** 1284/**
1285 * Continuation called by the statistics code once
1286 * we go the stat. Initiates hostlist download scheduling.
1287 *
1288 * @param cls closure
1289 * @param success #GNUNET_OK if statistics were
1290 * successfully obtained, #GNUNET_SYSERR if not.
1291 */
1292static void
1293stat_timeout_task (void *cls)
1294{
1295 GNUNET_STATISTICS_get_cancel (sget);
1296 sget = NULL;
1297 ti_check_download = GNUNET_SCHEDULER_add_now (&task_check,
1298 NULL);
1299}
1300
1301
1302/**
1279 * We've received the previous delay value from statistics. Remember it. 1303 * We've received the previous delay value from statistics. Remember it.
1280 * 1304 *
1281 * @param cls NULL, unused 1305 * @param cls NULL, unused
@@ -1637,7 +1661,6 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1637 sget = GNUNET_STATISTICS_get (stats, "hostlist", 1661 sget = GNUNET_STATISTICS_get (stats, "hostlist",
1638 gettext_noop 1662 gettext_noop
1639 ("# milliseconds between hostlist downloads"), 1663 ("# milliseconds between hostlist downloads"),
1640 GNUNET_TIME_UNIT_MINUTES,
1641 &primary_task, 1664 &primary_task,
1642 &process_stat, 1665 &process_stat,
1643 NULL); 1666 NULL);
@@ -1645,7 +1668,14 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1645 { 1668 {
1646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1669 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1647 "Statistics request failed, scheduling hostlist download\n"); 1670 "Statistics request failed, scheduling hostlist download\n");
1648 ti_check_download = GNUNET_SCHEDULER_add_now (&task_check, NULL); 1671 ti_check_download = GNUNET_SCHEDULER_add_now (&task_check,
1672 NULL);
1673 }
1674 else
1675 {
1676 ti_check_download = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1677 &stat_timeout_task,
1678 NULL);
1649 } 1679 }
1650 return GNUNET_OK; 1680 return GNUNET_OK;
1651} 1681}