aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
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/datastore
parent0aeea20846eb358a195e1255836618397b2bf9a2 (diff)
downloadgnunet-af628f3f58cd9d3cf5c1708cdc81fd743aea8076.tar.gz
gnunet-af628f3f58cd9d3cf5c1708cdc81fd743aea8076.zip
fix
Diffstat (limited to 'src/datastore')
-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
885{ 885{
886 886
887 /** 887 /**
888 * Plugin handle.
889 */
890 struct Plugin *plugin;
891
892 /**
893 * Function to call for the result (or the NULL). 888 * Function to call for the result (or the NULL).
894 */ 889 */
895 PluginDatumProcessor proc; 890 PluginDatumProcessor proc;
@@ -898,6 +893,16 @@ struct ReplCtx
898 * Closure for proc. 893 * Closure for proc.
899 */ 894 */
900 void *proc_cls; 895 void *proc_cls;
896
897 /**
898 * UID to use.
899 */
900 uint64_t uid;
901
902 /**
903 * Yes if UID was set.
904 */
905 int have_uid;
901}; 906};
902 907
903 908
@@ -932,7 +937,6 @@ repl_proc (void *cls,
932 uint64_t uid) 937 uint64_t uid)
933{ 938{
934 struct ReplCtx *rc = cls; 939 struct ReplCtx *rc = cls;
935 struct Plugin *plugin = rc->plugin;
936 int ret; 940 int ret;
937 941
938 ret = rc->proc (rc->proc_cls, 942 ret = rc->proc (rc->proc_cls,
@@ -940,24 +944,10 @@ repl_proc (void *cls,
940 size, data, 944 size, data,
941 type, priority, anonymity, expiration, 945 type, priority, anonymity, expiration,
942 uid); 946 uid);
943 if (NULL != key) 947 if (key != NULL)
944 { 948 {
945 sqlite3_bind_int64 (plugin->updRepl, 1, uid); 949 rc->uid = uid;
946 if (SQLITE_DONE != sqlite3_step (plugin->updRepl)) 950 rc->have_uid = GNUNET_YES;
947 {
948 LOG_SQLITE (plugin, NULL,
949 GNUNET_ERROR_TYPE_ERROR |
950 GNUNET_ERROR_TYPE_BULK, "sqlite3_step");
951 if (SQLITE_OK != sqlite3_reset (plugin->updRepl))
952 LOG_SQLITE (plugin, NULL,
953 GNUNET_ERROR_TYPE_ERROR |
954 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
955 return GNUNET_SYSERR;
956 }
957 if (SQLITE_OK != sqlite3_reset (plugin->delRow))
958 LOG_SQLITE (plugin, NULL,
959 GNUNET_ERROR_TYPE_ERROR |
960 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
961 } 951 }
962 return ret; 952 return ret;
963} 953}
@@ -985,10 +975,22 @@ sqlite_plugin_get_replication (void *cls,
985 "sqlite", 975 "sqlite",
986 "Getting random block based on replication order.\n"); 976 "Getting random block based on replication order.\n");
987#endif 977#endif
988 rc.plugin = plugin; 978 rc.have_uid = GNUNET_NO;
989 rc.proc = proc; 979 rc.proc = proc;
990 rc.proc_cls = proc_cls; 980 rc.proc_cls = proc_cls;
991 execute_get (plugin, plugin->selRepl, &repl_proc, &rc); 981 execute_get (plugin, plugin->selRepl, &repl_proc, &rc);
982 if (GNUNET_YES == rc.have_uid)
983 {
984 sqlite3_bind_int64 (plugin->updRepl, 1, rc.uid);
985 if (SQLITE_DONE != sqlite3_step (plugin->updRepl))
986 LOG_SQLITE (plugin, NULL,
987 GNUNET_ERROR_TYPE_ERROR |
988 GNUNET_ERROR_TYPE_BULK, "sqlite3_step");
989 if (SQLITE_OK != sqlite3_reset (plugin->updRepl))
990 LOG_SQLITE (plugin, NULL,
991 GNUNET_ERROR_TYPE_ERROR |
992 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
993 }
992} 994}
993 995
994 996