diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2010-03-12 12:36:50 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2010-03-12 12:36:50 +0000 |
commit | 3e3591494a1bd1ab65e907ba47e19e590644e1d5 (patch) | |
tree | 7144d056b877397aff501ec7f36e42f659350be8 /src/datastore/plugin_datastore_sqlite.c | |
parent | bec7561091b9e1ec56a9b0602a859de1a6164a91 (diff) |
enable stats get cancellation
git-svn-id: https://gnunet.org/svn/gnunet@10563 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/datastore/plugin_datastore_sqlite.c')
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 2fc28e13e9..9356b79edc 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -91,6 +91,7 @@ #define BUSY_TIMEOUT_MS 250 + /** * Context for all functions in this plugin. */ @@ -125,6 +126,11 @@ struct Plugin * Handle to the statistics service. */ struct GNUNET_STATISTICS_Handle *statistics; + + /** + * Handle for pending get request. + */ + struct GNUNET_STATISTICS_GetHandle *stat_get; /** * How much data are we currently storing @@ -1559,6 +1565,15 @@ process_stat_in (void *cls, #endif return GNUNET_OK; } + + +static void +process_stat_done (void *cls, + int success) +{ + struct Plugin *plugin = cls; + plugin->stat_get = NULL; +} /** @@ -1581,13 +1596,13 @@ libgnunet_plugin_datastore_sqlite_init (void *cls) plugin.statistics = GNUNET_STATISTICS_create (env->sched, "sqlite", env->cfg); - GNUNET_STATISTICS_get (plugin.statistics, - "sqlite", - QUOTA_STAT_NAME, - GNUNET_TIME_UNIT_MINUTES, - NULL, - &process_stat_in, - &plugin); + plugin.stat_get = GNUNET_STATISTICS_get (plugin.statistics, + "sqlite", + QUOTA_STAT_NAME, + GNUNET_TIME_UNIT_MINUTES, + &process_stat_done, + &process_stat_in, + &plugin); if (GNUNET_OK != database_setup (env->cfg, &plugin)) { @@ -1626,6 +1641,11 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) struct GNUNET_DATASTORE_PluginFunctions *api = cls; struct Plugin *plugin = api->cls; + if (plugin->stat_get != NULL) + { + GNUNET_STATISTICS_get_cancel (plugin->stat_get); + plugin->stat_get = NULL; + } fn = NULL; if (plugin->drop_on_shutdown) fn = GNUNET_strdup (plugin->fn); |