[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: fix crash in test if DB did
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: fix crash in test if DB did not yet exist |
Date: |
Sun, 26 Feb 2017 00:34:17 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new eb1c22361 fix crash in test if DB did not yet exist
eb1c22361 is described below
commit eb1c2236158eba266de1bc91d75d9c6d0714252b
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Feb 26 00:34:16 2017 +0100
fix crash in test if DB did not yet exist
---
src/datastore/plugin_datastore_sqlite.c | 52 ++++++++++++++++++---------
src/datastore/test_datastore_api_management.c | 19 ++++++++--
2 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/src/datastore/plugin_datastore_sqlite.c
b/src/datastore/plugin_datastore_sqlite.c
index 028117d26..9ab50714f 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -229,35 +229,41 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle
*cfg,
{
sqlite3_stmt *stmt;
char *afsdir;
-
#if ENULL_DEFINED
char *e;
#endif
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "datastore-sqlite",
- "FILENAME", &afsdir))
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "datastore-sqlite",
+ "FILENAME",
+ &afsdir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "datastore-sqlite", "FILENAME");
+ "datastore-sqlite",
+ "FILENAME");
return GNUNET_SYSERR;
}
if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
{
- if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (afsdir))
+ if (GNUNET_OK !=
+ GNUNET_DISK_directory_create_for_file (afsdir))
{
GNUNET_break (0);
GNUNET_free (afsdir);
return GNUNET_SYSERR;
}
/* database is new or got deleted, reset payload to zero! */
- plugin->env->duc (plugin->env->cls, 0);
+ if (NULL != plugin->env->duc)
+ plugin->env->duc (plugin->env->cls,
+ 0);
}
/* afsdir should be UTF-8-encoded. If it isn't, it's a bug */
plugin->fn = afsdir;
/* Open database and precompile statements */
- if (sqlite3_open (plugin->fn, &plugin->dbh) != SQLITE_OK)
+ if (SQLITE_OK !=
+ sqlite3_open (plugin->fn, &plugin->dbh))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "sqlite",
_("Unable to initialize SQLite: %s.\n"),
@@ -265,25 +271,32 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle
*cfg,
return GNUNET_SYSERR;
}
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA temp_store=MEMORY", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA synchronous=OFF", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA synchronous=OFF", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA legacy_file_format=OFF", NULL,
NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA legacy_file_format=OFF", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL", NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA auto_vacuum=INCREMENTAL", NULL,
NULL, ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA locking_mode=EXCLUSIVE", NULL,
NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA page_size=4092", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA page_size=4092", NULL, NULL,
ENULL));
- CHECK (SQLITE_OK == sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
+ CHECK (SQLITE_OK ==
+ sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
/* We have to do it here, because otherwise precompiling SQL might fail */
@@ -552,7 +565,9 @@ sqlite_plugin_put (void *cls,
switch (n)
{
case SQLITE_DONE:
- plugin->env->duc (plugin->env->cls, size +
GNUNET_DATASTORE_ENTRY_OVERHEAD);
+ if (NULL != plugin->env->duc)
+ plugin->env->duc (plugin->env->cls,
+ size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Stored new entry (%u bytes)\n",
size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
@@ -694,7 +709,8 @@ execute_get (struct Plugin *plugin,
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
- if (GNUNET_OK == delete_by_rowid (plugin, rowid))
+ if ( (GNUNET_OK == delete_by_rowid (plugin, rowid)) &&
+ (NULL != plugin->env->duc) )
plugin->env->duc (plugin->env->cls,
-(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
break;
@@ -713,7 +729,9 @@ execute_get (struct Plugin *plugin,
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
- if ((GNUNET_NO == ret) && (GNUNET_OK == delete_by_rowid (plugin, rowid)))
+ if ( (GNUNET_NO == ret) &&
+ (GNUNET_OK == delete_by_rowid (plugin, rowid)) &&
+ (NULL != plugin->env->duc) )
plugin->env->duc (plugin->env->cls,
-(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
return;
diff --git a/src/datastore/test_datastore_api_management.c
b/src/datastore/test_datastore_api_management.c
index 5e536d6c5..9a3e5446b 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -298,7 +298,21 @@ run (void *cls,
/**
- * check if plugin is actually working
+ * Function called when disk utilization changes, does nothing.
+ *
+ * @param cls closure
+ * @param delta change in utilization
+ */
+static void
+ignore_payload_cb (void *cls,
+ int delta)
+{
+ /* do nothing */
+}
+
+
+/**
+ * check if plugin is actually working
*/
static int
test_plugin (const char *cfg_name)
@@ -307,7 +321,7 @@ test_plugin (const char *cfg_name)
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_DATASTORE_PluginFunctions *api;
struct GNUNET_DATASTORE_PluginEnvironment env;
-
+
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
GNUNET_CONFIGURATION_load (cfg,
@@ -321,6 +335,7 @@ test_plugin (const char *cfg_name)
}
memset (&env, 0, sizeof (env));
env.cfg = cfg;
+ env.duc = &ignore_payload_cb;
GNUNET_snprintf (libname,
sizeof (libname),
"libgnunet_plugin_datastore_%s",
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: fix crash in test if DB did not yet exist,
gnunet <=