aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/datastore/datastore_api.c8
-rw-r--r--src/datastore/gnunet-service-datastore.c1
-rw-r--r--src/datastore/plugin_datastore.h6
-rw-r--r--src/datastore/plugin_datastore_sqlite.c128
-rw-r--r--src/datastore/plugin_datastore_template.c12
5 files changed, 149 insertions, 6 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 58fb5a795..db06fb75a 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -585,16 +585,18 @@ transmit_get_result (void *cls,
585 void *buf) 585 void *buf)
586{ 586{
587 struct GNUNET_DATASTORE_Handle *h = cls; 587 struct GNUNET_DATASTORE_Handle *h = cls;
588 GNUNET_DATASTORE_ContinuationWithStatus cont = h->response_proc; 588 GNUNET_DATASTORE_Iterator cont = h->response_proc;
589 uint16_t msize; 589 uint16_t msize;
590 590
591 if (buf == NULL) 591 if (buf == NULL)
592 { 592 {
593 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
594 _("Error transmitting message to datastore service.\n"));
593 h->response_proc = NULL; 595 h->response_proc = NULL;
594 h->message_size = 0; 596 h->message_size = 0;
595 cont (h->response_proc_cls, 597 cont (h->response_proc_cls,
596 GNUNET_SYSERR, 598 NULL, 0, NULL, 0, 0, 0,
597 gettext_noop ("Error transmitting message to datastore service.\n")); 599 GNUNET_TIME_UNIT_ZERO_ABS, 0);
598 return 0; 600 return 0;
599 } 601 }
600 msize = h->message_size; 602 msize = h->message_size;
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index f139998e9..220c114eb 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -1069,7 +1069,6 @@ handle_remove (void *cls,
1069 GNUNET_CRYPTO_hash (&dm[1], 1069 GNUNET_CRYPTO_hash (&dm[1],
1070 ntohl(dm->size), 1070 ntohl(dm->size),
1071 &vhash); 1071 &vhash);
1072 GNUNET_SERVER_client_keep (client);
1073 plugin->api->get (plugin->api->cls, 1072 plugin->api->get (plugin->api->cls,
1074 &dm->key, 1073 &dm->key,
1075 &vhash, 1074 &vhash,
diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h
index 2fefa2eca..2cebdbcd0 100644
--- a/src/datastore/plugin_datastore.h
+++ b/src/datastore/plugin_datastore.h
@@ -112,6 +112,8 @@ typedef int (*PluginIterator) (void *cls,
112/** 112/**
113 * Get an estimate of how much space the database is 113 * Get an estimate of how much space the database is
114 * currently using. 114 * currently using.
115 *
116 * @param cls closure
115 * @return number of bytes used on disk 117 * @return number of bytes used on disk
116 */ 118 */
117typedef unsigned long long (*PluginGetSize) (void *cls); 119typedef unsigned long long (*PluginGetSize) (void *cls);
@@ -185,6 +187,7 @@ typedef void (*PluginGet) (void *cls,
185 * Note that it is possible for multiple values to match this put. 187 * Note that it is possible for multiple values to match this put.
186 * In that case, all of the respective values are updated. 188 * In that case, all of the respective values are updated.
187 * 189 *
190 * @param cls closure
188 * @param uid unique identifier of the datum 191 * @param uid unique identifier of the datum
189 * @param delta by how much should the priority 192 * @param delta by how much should the priority
190 * change? If priority + delta < 0 the 193 * change? If priority + delta < 0 the
@@ -206,6 +209,7 @@ typedef int (*PluginUpdate) (void *cls,
206 * Select a subset of the items in the datastore and call 209 * Select a subset of the items in the datastore and call
207 * the given iterator for each of them. 210 * the given iterator for each of them.
208 * 211 *
212 * @param cls closure
209 * @param type entries of which type should be considered? 213 * @param type entries of which type should be considered?
210 * Use 0 for any type. 214 * Use 0 for any type.
211 * @param iter function to call on each matching value; however, 215 * @param iter function to call on each matching value; however,
@@ -223,6 +227,8 @@ typedef void (*PluginSelector) (void *cls,
223 227
224/** 228/**
225 * Drop database. 229 * Drop database.
230 *
231 * @param cls closure
226 */ 232 */
227typedef void (*PluginDrop) (void *cls); 233typedef void (*PluginDrop) (void *cls);
228 234
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 0b06c45b3..ff4b137b7 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -149,7 +149,10 @@ struct Plugin
149/** 149/**
150 * @brief Prepare a SQL statement 150 * @brief Prepare a SQL statement
151 * 151 *
152 * @param dbh handle to the database
152 * @param zSql SQL statement, UTF-8 encoded 153 * @param zSql SQL statement, UTF-8 encoded
154 * @param ppStmt set to the prepared statement
155 * @return 0 on success
153 */ 156 */
154static int 157static int
155sq_prepare (sqlite3 * dbh, const char *zSql, 158sq_prepare (sqlite3 * dbh, const char *zSql,
@@ -164,6 +167,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql,
164 167
165/** 168/**
166 * Create our database indices. 169 * Create our database indices.
170 *
171 * @param dbh handle to the database
167 */ 172 */
168static void 173static void
169create_indices (sqlite3 * dbh) 174create_indices (sqlite3 * dbh)
@@ -205,6 +210,8 @@ create_indices (sqlite3 * dbh)
205 * data structures (create tables and indices 210 * data structures (create tables and indices
206 * as needed as well). 211 * as needed as well).
207 * 212 *
213 * @param cfg our configuration
214 * @param plugin the plugin context (state for this module)
208 * @return GNUNET_OK on success 215 * @return GNUNET_OK on success
209 */ 216 */
210static int 217static int
@@ -335,6 +342,7 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
335/** 342/**
336 * Synchronize our utilization statistics with the 343 * Synchronize our utilization statistics with the
337 * statistics service. 344 * statistics service.
345 * @param plugin the plugin context (state for this module)
338 */ 346 */
339static void 347static void
340sync_stats (struct Plugin *plugin) 348sync_stats (struct Plugin *plugin)
@@ -350,6 +358,7 @@ sync_stats (struct Plugin *plugin)
350/** 358/**
351 * Shutdown database connection and associate data 359 * Shutdown database connection and associate data
352 * structures. 360 * structures.
361 * @param plugin the plugin context (state for this module)
353 */ 362 */
354static void 363static void
355database_shutdown (struct Plugin *plugin) 364database_shutdown (struct Plugin *plugin)
@@ -368,6 +377,8 @@ database_shutdown (struct Plugin *plugin)
368/** 377/**
369 * Get an estimate of how much space the database is 378 * Get an estimate of how much space the database is
370 * currently using. 379 * currently using.
380 *
381 * @param cls our plugin context
371 * @return number of bytes used on disk 382 * @return number of bytes used on disk
372 */ 383 */
373static unsigned long long sqlite_plugin_get_size (void *cls) 384static unsigned long long sqlite_plugin_get_size (void *cls)
@@ -380,6 +391,9 @@ static unsigned long long sqlite_plugin_get_size (void *cls)
380/** 391/**
381 * Delete the database entry with the given 392 * Delete the database entry with the given
382 * row identifier. 393 * row identifier.
394 *
395 * @param plugin the plugin context (state for this module)
396 * @param rid the ID of the row to delete
383 */ 397 */
384static int 398static int
385delete_by_rowid (struct Plugin* plugin, 399delete_by_rowid (struct Plugin* plugin,
@@ -502,6 +516,7 @@ struct NextContext
502 * Continuation of "sqlite_next_request". 516 * Continuation of "sqlite_next_request".
503 * 517 *
504 * @param cls the next context 518 * @param cls the next context
519 * @param tc the task context (unused)
505 */ 520 */
506static void 521static void
507sqlite_next_request_cont (void *cls, 522sqlite_next_request_cont (void *cls,
@@ -743,6 +758,7 @@ sqlite_plugin_put (void *cls,
743 * Note that it is possible for multiple values to match this put. 758 * Note that it is possible for multiple values to match this put.
744 * In that case, all of the respective values are updated. 759 * In that case, all of the respective values are updated.
745 * 760 *
761 * @param cls the plugin context (state for this module)
746 * @param uid unique identifier of the datum 762 * @param uid unique identifier of the datum
747 * @param delta by how much should the priority 763 * @param delta by how much should the priority
748 * change? If priority + delta < 0 the 764 * change? If priority + delta < 0 the
@@ -785,18 +801,57 @@ sqlite_plugin_update (void *cls,
785} 801}
786 802
787 803
804/**
805 * Internal context for an iteration.
806 */
788struct IterContext 807struct IterContext
789{ 808{
809 /**
810 * FIXME.
811 */
790 sqlite3_stmt *stmt_1; 812 sqlite3_stmt *stmt_1;
813
814 /**
815 * FIXME.
816 */
791 sqlite3_stmt *stmt_2; 817 sqlite3_stmt *stmt_2;
818
819 /**
820 * FIXME.
821 */
792 int is_asc; 822 int is_asc;
823
824 /**
825 * FIXME.
826 */
793 int is_prio; 827 int is_prio;
828
829 /**
830 * FIXME.
831 */
794 int is_migr; 832 int is_migr;
833
834 /**
835 * FIXME.
836 */
795 int limit_nonanonymous; 837 int limit_nonanonymous;
838
839 /**
840 * Desired type for blocks returned by this iterator.
841 */
796 uint32_t type; 842 uint32_t type;
797}; 843};
798 844
799 845
846/**
847 * Prepare our SQL query to obtain the next record from the database.
848 *
849 * @param cls our "struct IterContext"
850 * @param nc NULL to terminate the iteration, otherwise our context for
851 * getting the next result.
852 * @return GNUNET_OK on success, GNUNET_NO if there are no more results,
853 * GNUNET_SYSERR on error (or end of iteration)
854 */
800static int 855static int
801iter_next_prepare (void *cls, 856iter_next_prepare (void *cls,
802 struct NextContext *nc) 857 struct NextContext *nc)
@@ -903,12 +958,18 @@ iter_next_prepare (void *cls,
903 * Call a method for each key in the database and 958 * Call a method for each key in the database and
904 * call the callback method on it. 959 * call the callback method on it.
905 * 960 *
961 * @param plugin our plugin context
906 * @param type entries of which type should be considered? 962 * @param type entries of which type should be considered?
963 * @param is_asc are we iterating in ascending order?
964 * @param is_prio are we iterating by priority (otherwise by expiration)
965 * @param is_migr are we iterating in migration order?
966 * @param limit_nonanonymous are we restricting results to those with anonymity
967 * level zero?
968 * @param stmt_str_1 first SQL statement to execute
969 * @param stmt_str_2 SQL statement to execute to get "more" results (inner iteration)
907 * @param iter function to call on each matching value; 970 * @param iter function to call on each matching value;
908 * will be called once with a NULL value at the end 971 * will be called once with a NULL value at the end
909 * @param iter_cls closure for iter 972 * @param iter_cls closure for iter
910 * @return the number of results processed,
911 * GNUNET_SYSERR on error
912 */ 973 */
913static void 974static void
914basic_iter (struct Plugin *plugin, 975basic_iter (struct Plugin *plugin,
@@ -987,6 +1048,7 @@ basic_iter (struct Plugin *plugin,
987 * Select a subset of the items in the datastore and call 1048 * Select a subset of the items in the datastore and call
988 * the given iterator for each of them. 1049 * the given iterator for each of them.
989 * 1050 *
1051 * @param cls our plugin context
990 * @param type entries of which type should be considered? 1052 * @param type entries of which type should be considered?
991 * Use 0 for any type. 1053 * Use 0 for any type.
992 * @param iter function to call on each matching value; 1054 * @param iter function to call on each matching value;
@@ -1013,6 +1075,7 @@ sqlite_plugin_iter_low_priority (void *cls,
1013 * Select a subset of the items in the datastore and call 1075 * Select a subset of the items in the datastore and call
1014 * the given iterator for each of them. 1076 * the given iterator for each of them.
1015 * 1077 *
1078 * @param cls our plugin context
1016 * @param type entries of which type should be considered? 1079 * @param type entries of which type should be considered?
1017 * Use 0 for any type. 1080 * Use 0 for any type.
1018 * @param iter function to call on each matching value; 1081 * @param iter function to call on each matching value;
@@ -1051,6 +1114,7 @@ sqlite_plugin_iter_zero_anonymity (void *cls,
1051 * Select a subset of the items in the datastore and call 1114 * Select a subset of the items in the datastore and call
1052 * the given iterator for each of them. 1115 * the given iterator for each of them.
1053 * 1116 *
1117 * @param cls our plugin context
1054 * @param type entries of which type should be considered? 1118 * @param type entries of which type should be considered?
1055 * Use 0 for any type. 1119 * Use 0 for any type.
1056 * @param iter function to call on each matching value; 1120 * @param iter function to call on each matching value;
@@ -1087,6 +1151,7 @@ sqlite_plugin_iter_ascending_expiration (void *cls,
1087 * Select a subset of the items in the datastore and call 1151 * Select a subset of the items in the datastore and call
1088 * the given iterator for each of them. 1152 * the given iterator for each of them.
1089 * 1153 *
1154 * @param cls our plugin context
1090 * @param type entries of which type should be considered? 1155 * @param type entries of which type should be considered?
1091 * Use 0 for any type. 1156 * Use 0 for any type.
1092 * @param iter function to call on each matching value; 1157 * @param iter function to call on each matching value;
@@ -1116,6 +1181,15 @@ sqlite_plugin_iter_migration_order (void *cls,
1116} 1181}
1117 1182
1118 1183
1184/**
1185 * Call sqlite using the already prepared query to get
1186 * the next result.
1187 *
1188 * @param cls not used
1189 * @param nc context with the prepared query
1190 * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO if
1191 * there are no more results
1192 */
1119static int 1193static int
1120all_next_prepare (void *cls, 1194all_next_prepare (void *cls,
1121 struct NextContext *nc) 1195 struct NextContext *nc)
@@ -1152,6 +1226,7 @@ all_next_prepare (void *cls,
1152 * Select a subset of the items in the datastore and call 1226 * Select a subset of the items in the datastore and call
1153 * the given iterator for each of them. 1227 * the given iterator for each of them.
1154 * 1228 *
1229 * @param cls our plugin context
1155 * @param type entries of which type should be considered? 1230 * @param type entries of which type should be considered?
1156 * Use 0 for any type. 1231 * Use 0 for any type.
1157 * @param iter function to call on each matching value; 1232 * @param iter function to call on each matching value;
@@ -1189,18 +1264,59 @@ sqlite_plugin_iter_all_now (void *cls,
1189} 1264}
1190 1265
1191 1266
1267/**
1268 * FIXME.
1269 */
1192struct GetNextContext 1270struct GetNextContext
1193{ 1271{
1272
1273 /**
1274 * FIXME.
1275 */
1194 int total; 1276 int total;
1277
1278 /**
1279 * FIXME.
1280 */
1195 int off; 1281 int off;
1282
1283 /**
1284 * FIXME.
1285 */
1196 int have_vhash; 1286 int have_vhash;
1287
1288 /**
1289 * FIXME.
1290 */
1197 unsigned int type; 1291 unsigned int type;
1292
1293 /**
1294 * FIXME.
1295 */
1198 sqlite3_stmt *stmt; 1296 sqlite3_stmt *stmt;
1297
1298 /**
1299 * FIXME.
1300 */
1199 GNUNET_HashCode key; 1301 GNUNET_HashCode key;
1302
1303 /**
1304 * FIXME.
1305 */
1200 GNUNET_HashCode vhash; 1306 GNUNET_HashCode vhash;
1201}; 1307};
1202 1308
1203 1309
1310
1311/**
1312 * FIXME.
1313 *
1314 * @param cls our "struct GetNextContext*"
1315 * @param nc FIXME
1316 * @return GNUNET_YES if there are more results,
1317 * GNUNET_NO if there are no more results,
1318 * GNUNET_SYSERR on internal error
1319 */
1204static int 1320static int
1205get_next_prepare (void *cls, 1321get_next_prepare (void *cls,
1206 struct NextContext *nc) 1322 struct NextContext *nc)
@@ -1381,6 +1497,8 @@ sqlite_plugin_get (void *cls,
1381 1497
1382/** 1498/**
1383 * Drop database. 1499 * Drop database.
1500 *
1501 * @param cls our plugin context
1384 */ 1502 */
1385static void 1503static void
1386sqlite_plugin_drop (void *cls) 1504sqlite_plugin_drop (void *cls)
@@ -1415,6 +1533,9 @@ process_stat_in (void *cls,
1415 1533
1416/** 1534/**
1417 * Entry point for the plugin. 1535 * Entry point for the plugin.
1536 *
1537 * @param cls the "struct GNUNET_DATASTORE_PluginEnvironment*"
1538 * @return NULL on error, othrewise the plugin context
1418 */ 1539 */
1419void * 1540void *
1420libgnunet_plugin_datastore_sqlite_init (void *cls) 1541libgnunet_plugin_datastore_sqlite_init (void *cls)
@@ -1464,6 +1585,9 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
1464 1585
1465/** 1586/**
1466 * Exit point from the plugin. 1587 * Exit point from the plugin.
1588 *
1589 * @param cls the plugin context (as returned by "init")
1590 * @return always NULL
1467 */ 1591 */
1468void * 1592void *
1469libgnunet_plugin_datastore_sqlite_done (void *cls) 1593libgnunet_plugin_datastore_sqlite_done (void *cls)
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c
index 4bfb452ed..7f31ff703 100644
--- a/src/datastore/plugin_datastore_template.c
+++ b/src/datastore/plugin_datastore_template.c
@@ -43,6 +43,8 @@ struct Plugin
43/** 43/**
44 * Get an estimate of how much space the database is 44 * Get an estimate of how much space the database is
45 * currently using. 45 * currently using.
46 *
47 * @param cls our "struct Plugin*"
46 * @return number of bytes used on disk 48 * @return number of bytes used on disk
47 */ 49 */
48static unsigned long long template_plugin_get_size (void *cls) 50static unsigned long long template_plugin_get_size (void *cls)
@@ -142,6 +144,7 @@ template_plugin_get (void *cls,
142 * Note that it is possible for multiple values to match this put. 144 * Note that it is possible for multiple values to match this put.
143 * In that case, all of the respective values are updated. 145 * In that case, all of the respective values are updated.
144 * 146 *
147 * @param cls our "struct Plugin*"
145 * @param uid unique identifier of the datum 148 * @param uid unique identifier of the datum
146 * @param delta by how much should the priority 149 * @param delta by how much should the priority
147 * change? If priority + delta < 0 the 150 * change? If priority + delta < 0 the
@@ -169,6 +172,7 @@ template_plugin_update (void *cls,
169 * Select a subset of the items in the datastore and call 172 * Select a subset of the items in the datastore and call
170 * the given iterator for each of them. 173 * the given iterator for each of them.
171 * 174 *
175 * @param cls our "struct Plugin*"
172 * @param type entries of which type should be considered? 176 * @param type entries of which type should be considered?
173 * Use 0 for any type. 177 * Use 0 for any type.
174 * @param iter function to call on each matching value; 178 * @param iter function to call on each matching value;
@@ -211,6 +215,7 @@ template_plugin_iter_zero_anonymity (void *cls,
211 * Select a subset of the items in the datastore and call 215 * Select a subset of the items in the datastore and call
212 * the given iterator for each of them. 216 * the given iterator for each of them.
213 * 217 *
218 * @param cls our "struct Plugin*"
214 * @param type entries of which type should be considered? 219 * @param type entries of which type should be considered?
215 * Use 0 for any type. 220 * Use 0 for any type.
216 * @param iter function to call on each matching value; 221 * @param iter function to call on each matching value;
@@ -232,6 +237,7 @@ template_plugin_iter_ascending_expiration (void *cls,
232 * Select a subset of the items in the datastore and call 237 * Select a subset of the items in the datastore and call
233 * the given iterator for each of them. 238 * the given iterator for each of them.
234 * 239 *
240 * @param cls our "struct Plugin*"
235 * @param type entries of which type should be considered? 241 * @param type entries of which type should be considered?
236 * Use 0 for any type. 242 * Use 0 for any type.
237 * @param iter function to call on each matching value; 243 * @param iter function to call on each matching value;
@@ -253,6 +259,7 @@ template_plugin_iter_migration_order (void *cls,
253 * Select a subset of the items in the datastore and call 259 * Select a subset of the items in the datastore and call
254 * the given iterator for each of them. 260 * the given iterator for each of them.
255 * 261 *
262 * @param cls our "struct Plugin*"
256 * @param type entries of which type should be considered? 263 * @param type entries of which type should be considered?
257 * Use 0 for any type. 264 * Use 0 for any type.
258 * @param iter function to call on each matching value; 265 * @param iter function to call on each matching value;
@@ -281,6 +288,9 @@ template_plugin_drop (void *cls)
281 288
282/** 289/**
283 * Entry point for the plugin. 290 * Entry point for the plugin.
291 *
292 * @param cls the "struct GNUNET_DATASTORE_PluginEnvironment*"
293 * @return our "struct Plugin*"
284 */ 294 */
285void * 295void *
286libgnunet_plugin_datastore_template_init (void *cls) 296libgnunet_plugin_datastore_template_init (void *cls)
@@ -312,6 +322,8 @@ libgnunet_plugin_datastore_template_init (void *cls)
312 322
313/** 323/**
314 * Exit point from the plugin. 324 * Exit point from the plugin.
325 * @param cls our "struct Plugin*"
326 * @return always NULL
315 */ 327 */
316void * 328void *
317libgnunet_plugin_datastore_template_done (void *cls) 329libgnunet_plugin_datastore_template_done (void *cls)