plugin_datastore_sqlite.c
libgnunet_plugin_datastore_sqlite_la_LIBADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
$(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
libgnunet_plugin_datastore_sqlite_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
static unsigned long long quota;
/**
- * How much space are we using for the cache?
- * (space available for insertions that will be
- * instantly reclaimed by discarding less
- * important content --- or possibly whatever
- * we just inserted into the "cache").
+ * How much space are we using for the cache? (space available for
+ * insertions that will be instantly reclaimed by discarding less
+ * important content --- or possibly whatever we just inserted into
+ * the "cache").
*/
static unsigned long long cache_size;
(0 == *need) ? GNUNET_YES : GNUNET_NO);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting %llu bytes of low-priority content (still trying to recover %llu bytes)\n",
+ "Deleting %llu bytes of low-priority content (still trying to free another %llu bytes)\n",
size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
*need);
#endif
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to recover %llu bytes of cache space\n",
+ "Asked to free up %llu bytes of cache space\n",
need);
#endif
n = GNUNET_malloc (sizeof(unsigned long long));
*/
#include "platform.h"
+#include "gnunet_arm_service.h"
#include "gnunet_statistics_service.h"
#include "plugin_datastore.h"
#include <sqlite3.h>
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
/**
* After how many payload-changing operations
nc->end_it = GNUNET_YES;
return;
}
+#if DEBUG_SQLITE
+ if (ret == GNUNET_NO)
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Asked to remove entry %llu (%u bytes)\n",
+ (unsigned long long) rowid,
+ size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
+#endif
if ( (ret == GNUNET_NO) &&
(GNUNET_OK == delete_by_rowid (plugin, rowid)) )
{
plugin->payload -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
plugin->lastSync++;
+#if DEBUG_SQLITE
+ if (ret == GNUNET_NO)
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Removed entry %llu (%u bytes), new payload is %llu\n",
+ (unsigned long long) rowid,
+ size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
+ (unsigned long long) plugin->payload);
+#endif
if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
sync_stats (plugin);
}
GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
plugin->lastSync++;
plugin->payload += size + GNUNET_DATASTORE_ENTRY_OVERHEAD;
+#if DEBUG_SQLITE
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Stored new entry (%u bytes), new payload is %llu\n",
+ size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
+ (unsigned long long) plugin->payload);
+#endif
if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
sync_stats (plugin);
return GNUNET_OK;
process_stat_in (void *cls,
const char *subsystem,
const char *name,
- unsigned long long value,
+ uint64_t value,
int is_persistent)
{
struct Plugin *plugin = cls;
plugin->payload += value;
+#if DEBUG_SQLITE
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Notification from statistics about existing payload (%llu), new payload is %llu\n",
+ value,
+ (unsigned long long) plugin->payload);
+#endif
return GNUNET_OK;
}
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
plugin.env = env;
+ GNUNET_ARM_start_services (env->cfg, env->sched, "statistics");
plugin.statistics = GNUNET_STATISTICS_create (env->sched,
"sqlite",
env->cfg);
database_setup (env->cfg, &plugin))
{
database_shutdown (&plugin);
+ GNUNET_ARM_stop_services (env->cfg, env->sched, "statistics");
return NULL;
}
api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
plugin->env = NULL;
plugin->payload = 0;
GNUNET_STATISTICS_destroy (plugin->statistics);
+ GNUNET_ARM_stop_services (plugin->env->cfg, plugin->env->sched, "statistics");
GNUNET_free (api);
if (fn != NULL)
{
process_stat (void *cls,
const char *subsystem,
const char *name,
- unsigned long long value,
+ uint64_t value,
int is_persistent)
{
- hostlist_delay.value = (uint64_t) value;
+ hostlist_delay.value = value;
return GNUNET_OK;
}
typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
const char *subsystem,
const char *name,
- unsigned long long value,
+ uint64_t value,
int is_persistent);
/**
void
GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
const char *name,
- unsigned long long value, int make_persistent);
+ uint64_t value, int make_persistent);
/**
* Set statistic value for the peer. Will always use our
void
GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
const char *name,
- long long delta, int make_persistent);
+ int64_t delta, int make_persistent);
static int
printer (void *cls,
const char *subsystem,
- const char *name, unsigned long long value, int is_persistent)
+ const char *name,
+ uint64_t value, int is_persistent)
{
FPRINTF (stdout,
"%s%-20s %-40s: %16llu\n",
- is_persistent ? "!" : " ", subsystem, _(name), value);
+ is_persistent ? "!" : " ", subsystem, _(name),
+ (unsigned long long) value);
return GNUNET_OK;
}
ret = 1;
return;
}
- GNUNET_STATISTICS_set (h, name, val, persistent);
+ GNUNET_STATISTICS_set (h, name, (uint64_t) val, persistent);
GNUNET_STATISTICS_destroy (h);
return;
}
/**
* Associated value.
*/
- unsigned long long value;
+ uint64_t value;
/**
* Flag for SET/UPDATE actions.
add_setter_action (struct GNUNET_STATISTICS_Handle *h,
const char *name,
int make_persistent,
- unsigned long long value, enum ActionType type)
+ uint64_t value, enum ActionType type)
{
struct ActionItem *ai;
size_t slen;
void
GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
const char *name,
- unsigned long long value, int make_persistent)
+ uint64_t value, int make_persistent)
{
add_setter_action (handle, name, make_persistent, value, ACTION_SET);
}
void
GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
const char *name,
- long long delta, int make_persistent)
+ int64_t delta, int make_persistent)
{
add_setter_action (handle, name, make_persistent,
(unsigned long long) delta, ACTION_UPDATE);