summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-05-05 13:52:09 +0000
committerChristian Grothoff <christian@grothoff.org>2011-05-05 13:52:09 +0000
commitaf628f3f58cd9d3cf5c1708cdc81fd743aea8076 (patch)
treedef47d6f5df8c28424d682258d4bef923d466176 /src
parent0aeea20846eb358a195e1255836618397b2bf9a2 (diff)
fix
Diffstat (limited to 'src')
-rw-r--r--src/datastore/plugin_datastore_sqlite.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 8ae8f54af..3267869d5 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -885,11 +885,6 @@ struct ReplCtx
{
/**
- * Plugin handle.
- */
- struct Plugin *plugin;
-
- /**
* Function to call for the result (or the NULL).
*/
PluginDatumProcessor proc;
@@ -898,6 +893,16 @@ struct ReplCtx
* Closure for proc.
*/
void *proc_cls;
+
+ /**
+ * UID to use.
+ */
+ uint64_t uid;
+
+ /**
+ * Yes if UID was set.
+ */
+ int have_uid;
};
@@ -932,7 +937,6 @@ repl_proc (void *cls,
uint64_t uid)
{
struct ReplCtx *rc = cls;
- struct Plugin *plugin = rc->plugin;
int ret;
ret = rc->proc (rc->proc_cls,
@@ -940,24 +944,10 @@ repl_proc (void *cls,
size, data,
type, priority, anonymity, expiration,
uid);
- if (NULL != key)
+ if (key != NULL)
{
- sqlite3_bind_int64 (plugin->updRepl, 1, uid);
- if (SQLITE_DONE != sqlite3_step (plugin->updRepl))
- {
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR |
- GNUNET_ERROR_TYPE_BULK, "sqlite3_step");
- if (SQLITE_OK != sqlite3_reset (plugin->updRepl))
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR |
- GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
- return GNUNET_SYSERR;
- }
- if (SQLITE_OK != sqlite3_reset (plugin->delRow))
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR |
- GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
+ rc->uid = uid;
+ rc->have_uid = GNUNET_YES;
}
return ret;
}
@@ -985,10 +975,22 @@ sqlite_plugin_get_replication (void *cls,
"sqlite",
"Getting random block based on replication order.\n");
#endif
- rc.plugin = plugin;
+ rc.have_uid = GNUNET_NO;
rc.proc = proc;
rc.proc_cls = proc_cls;
- execute_get (plugin, plugin->selRepl, &repl_proc, &rc);
+ execute_get (plugin, plugin->selRepl, &repl_proc, &rc);
+ if (GNUNET_YES == rc.have_uid)
+ {
+ sqlite3_bind_int64 (plugin->updRepl, 1, rc.uid);
+ if (SQLITE_DONE != sqlite3_step (plugin->updRepl))
+ LOG_SQLITE (plugin, NULL,
+ GNUNET_ERROR_TYPE_ERROR |
+ GNUNET_ERROR_TYPE_BULK, "sqlite3_step");
+ if (SQLITE_OK != sqlite3_reset (plugin->updRepl))
+ LOG_SQLITE (plugin, NULL,
+ GNUNET_ERROR_TYPE_ERROR |
+ GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
+ }
}