diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/datastore/plugin_datastore_mysql.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/datastore/plugin_datastore_mysql.c')
-rw-r--r-- | src/datastore/plugin_datastore_mysql.c | 1114 |
1 files changed, 554 insertions, 560 deletions
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 68371d389..c670a6d99 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file datastore/plugin_datastore_mysql.c | 22 | * @file datastore/plugin_datastore_mysql.c |
@@ -129,8 +129,7 @@ | |||
129 | /** | 129 | /** |
130 | * Context for all functions in this plugin. | 130 | * Context for all functions in this plugin. |
131 | */ | 131 | */ |
132 | struct Plugin | 132 | struct Plugin { |
133 | { | ||
134 | /** | 133 | /** |
135 | * Our execution environment. | 134 | * Our execution environment. |
136 | */ | 135 | */ |
@@ -150,41 +149,41 @@ struct Plugin | |||
150 | #define DELETE_ENTRY_BY_UID "DELETE FROM gn090 WHERE uid=?" | 149 | #define DELETE_ENTRY_BY_UID "DELETE FROM gn090 WHERE uid=?" |
151 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_uid; | 150 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_uid; |
152 | 151 | ||
153 | #define DELETE_ENTRY_BY_HASH_VALUE "DELETE FROM gn090 "\ | 152 | #define DELETE_ENTRY_BY_HASH_VALUE "DELETE FROM gn090 " \ |
154 | "WHERE hash = ? AND "\ | 153 | "WHERE hash = ? AND " \ |
155 | "value = ? "\ | 154 | "value = ? " \ |
156 | "LIMIT 1" | 155 | "LIMIT 1" |
157 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_hash_value; | 156 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_hash_value; |
158 | 157 | ||
159 | #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, uid" | 158 | #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, uid" |
160 | 159 | ||
161 | #define SELECT_ENTRY "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 160 | #define SELECT_ENTRY "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
162 | "WHERE uid >= ? AND "\ | 161 | "WHERE uid >= ? AND " \ |
163 | "(rvalue >= ? OR 0 = ?) "\ | 162 | "(rvalue >= ? OR 0 = ?) " \ |
164 | "ORDER BY uid LIMIT 1" | 163 | "ORDER BY uid LIMIT 1" |
165 | struct GNUNET_MYSQL_StatementHandle *select_entry; | 164 | struct GNUNET_MYSQL_StatementHandle *select_entry; |
166 | 165 | ||
167 | #define SELECT_ENTRY_BY_HASH "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 166 | #define SELECT_ENTRY_BY_HASH "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
168 | "FORCE INDEX (idx_hash_type_uid) "\ | 167 | "FORCE INDEX (idx_hash_type_uid) " \ |
169 | "WHERE hash=? AND "\ | 168 | "WHERE hash=? AND " \ |
170 | "uid >= ? AND "\ | 169 | "uid >= ? AND " \ |
171 | "(rvalue >= ? OR 0 = ?) "\ | 170 | "(rvalue >= ? OR 0 = ?) " \ |
172 | "ORDER BY uid LIMIT 1" | 171 | "ORDER BY uid LIMIT 1" |
173 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash; | 172 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash; |
174 | 173 | ||
175 | #define SELECT_ENTRY_BY_HASH_AND_TYPE "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 174 | #define SELECT_ENTRY_BY_HASH_AND_TYPE "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
176 | "FORCE INDEX (idx_hash_type_uid) "\ | 175 | "FORCE INDEX (idx_hash_type_uid) " \ |
177 | "WHERE hash = ? AND "\ | 176 | "WHERE hash = ? AND " \ |
178 | "type = ? AND "\ | 177 | "type = ? AND " \ |
179 | "uid >= ? AND "\ | 178 | "uid >= ? AND " \ |
180 | "(rvalue >= ? OR 0 = ?) "\ | 179 | "(rvalue >= ? OR 0 = ?) " \ |
181 | "ORDER BY uid LIMIT 1" | 180 | "ORDER BY uid LIMIT 1" |
182 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash_and_type; | 181 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash_and_type; |
183 | 182 | ||
184 | #define UPDATE_ENTRY "UPDATE gn090 SET "\ | 183 | #define UPDATE_ENTRY "UPDATE gn090 SET " \ |
185 | "prio = prio + ?, "\ | 184 | "prio = prio + ?, " \ |
186 | "repl = repl + ?, "\ | 185 | "repl = repl + ?, " \ |
187 | "expire = GREATEST(expire, ?) "\ | 186 | "expire = GREATEST(expire, ?) " \ |
188 | "WHERE hash = ? AND vhash = ?" | 187 | "WHERE hash = ? AND vhash = ?" |
189 | struct GNUNET_MYSQL_StatementHandle *update_entry; | 188 | struct GNUNET_MYSQL_StatementHandle *update_entry; |
190 | 189 | ||
@@ -194,31 +193,31 @@ struct Plugin | |||
194 | #define SELECT_SIZE "SELECT SUM(LENGTH(value)+256) FROM gn090" | 193 | #define SELECT_SIZE "SELECT SUM(LENGTH(value)+256) FROM gn090" |
195 | struct GNUNET_MYSQL_StatementHandle *get_size; | 194 | struct GNUNET_MYSQL_StatementHandle *get_size; |
196 | 195 | ||
197 | #define SELECT_IT_NON_ANONYMOUS "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 196 | #define SELECT_IT_NON_ANONYMOUS "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
198 | "FORCE INDEX (idx_anonLevel_type_rvalue) "\ | 197 | "FORCE INDEX (idx_anonLevel_type_rvalue) " \ |
199 | "WHERE anonLevel=0 AND "\ | 198 | "WHERE anonLevel=0 AND " \ |
200 | "type=? AND "\ | 199 | "type=? AND " \ |
201 | "uid >= ? "\ | 200 | "uid >= ? " \ |
202 | "ORDER BY uid LIMIT 1" | 201 | "ORDER BY uid LIMIT 1" |
203 | struct GNUNET_MYSQL_StatementHandle *zero_iter; | 202 | struct GNUNET_MYSQL_StatementHandle *zero_iter; |
204 | 203 | ||
205 | #define SELECT_IT_EXPIRATION "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 204 | #define SELECT_IT_EXPIRATION "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
206 | "FORCE INDEX (idx_expire) "\ | 205 | "FORCE INDEX (idx_expire) " \ |
207 | "WHERE expire < ? "\ | 206 | "WHERE expire < ? " \ |
208 | "ORDER BY expire ASC LIMIT 1" | 207 | "ORDER BY expire ASC LIMIT 1" |
209 | struct GNUNET_MYSQL_StatementHandle *select_expiration; | 208 | struct GNUNET_MYSQL_StatementHandle *select_expiration; |
210 | 209 | ||
211 | #define SELECT_IT_PRIORITY "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 210 | #define SELECT_IT_PRIORITY "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
212 | "FORCE INDEX (idx_prio) "\ | 211 | "FORCE INDEX (idx_prio) " \ |
213 | "ORDER BY prio ASC LIMIT 1" | 212 | "ORDER BY prio ASC LIMIT 1" |
214 | struct GNUNET_MYSQL_StatementHandle *select_priority; | 213 | struct GNUNET_MYSQL_StatementHandle *select_priority; |
215 | 214 | ||
216 | #define SELECT_IT_REPLICATION "SELECT " RESULT_COLUMNS " FROM gn090 "\ | 215 | #define SELECT_IT_REPLICATION "SELECT " RESULT_COLUMNS " FROM gn090 " \ |
217 | "FORCE INDEX (idx_repl_rvalue) "\ | 216 | "FORCE INDEX (idx_repl_rvalue) " \ |
218 | "WHERE repl=? AND "\ | 217 | "WHERE repl=? AND " \ |
219 | " (rvalue>=? OR"\ | 218 | " (rvalue>=? OR" \ |
220 | " NOT EXISTS (SELECT 1 FROM gn090 FORCE INDEX (idx_repl_rvalue) WHERE repl=? AND rvalue>=?)) "\ | 219 | " NOT EXISTS (SELECT 1 FROM gn090 FORCE INDEX (idx_repl_rvalue) WHERE repl=? AND rvalue>=?)) " \ |
221 | "ORDER BY rvalue ASC "\ | 220 | "ORDER BY rvalue ASC " \ |
222 | "LIMIT 1" | 221 | "LIMIT 1" |
223 | struct GNUNET_MYSQL_StatementHandle *select_replication; | 222 | struct GNUNET_MYSQL_StatementHandle *select_replication; |
224 | 223 | ||
@@ -227,7 +226,6 @@ struct Plugin | |||
227 | 226 | ||
228 | #define GET_ALL_KEYS "SELECT hash from gn090" | 227 | #define GET_ALL_KEYS "SELECT hash from gn090" |
229 | struct GNUNET_MYSQL_StatementHandle *get_all_keys; | 228 | struct GNUNET_MYSQL_StatementHandle *get_all_keys; |
230 | |||
231 | }; | 229 | }; |
232 | 230 | ||
233 | #define MAX_PARAM 16 | 231 | #define MAX_PARAM 16 |
@@ -240,29 +238,29 @@ struct Plugin | |||
240 | * @return #GNUNET_OK on success, #GNUNET_NO if no such value exists, #GNUNET_SYSERR on error | 238 | * @return #GNUNET_OK on success, #GNUNET_NO if no such value exists, #GNUNET_SYSERR on error |
241 | */ | 239 | */ |
242 | static int | 240 | static int |
243 | do_delete_entry (struct Plugin *plugin, | 241 | do_delete_entry(struct Plugin *plugin, |
244 | unsigned long long uid) | 242 | unsigned long long uid) |
245 | { | 243 | { |
246 | int ret; | 244 | int ret; |
247 | uint64_t uid64 = (uint64_t) uid; | 245 | uint64_t uid64 = (uint64_t)uid; |
248 | struct GNUNET_MY_QueryParam params_delete[] = { | 246 | struct GNUNET_MY_QueryParam params_delete[] = { |
249 | GNUNET_MY_query_param_uint64 (&uid64), | 247 | GNUNET_MY_query_param_uint64(&uid64), |
250 | GNUNET_MY_query_param_end | 248 | GNUNET_MY_query_param_end |
251 | }; | 249 | }; |
252 | 250 | ||
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 251 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
254 | "Deleting value %llu from gn090 table\n", | 252 | "Deleting value %llu from gn090 table\n", |
255 | uid); | 253 | uid); |
256 | ret = GNUNET_MY_exec_prepared (plugin->mc, | 254 | ret = GNUNET_MY_exec_prepared(plugin->mc, |
257 | plugin->delete_entry_by_uid, | 255 | plugin->delete_entry_by_uid, |
258 | params_delete); | 256 | params_delete); |
259 | if (ret >= 0) | 257 | if (ret >= 0) |
260 | { | 258 | { |
261 | return GNUNET_OK; | 259 | return GNUNET_OK; |
262 | } | 260 | } |
263 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 261 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
264 | "Deleting value %llu from gn090 table failed\n", | 262 | "Deleting value %llu from gn090 table failed\n", |
265 | (unsigned long long) uid); | 263 | (unsigned long long)uid); |
266 | return ret; | 264 | return ret; |
267 | } | 265 | } |
268 | 266 | ||
@@ -275,8 +273,8 @@ do_delete_entry (struct Plugin *plugin, | |||
275 | * @return number of bytes used on disk | 273 | * @return number of bytes used on disk |
276 | */ | 274 | */ |
277 | static void | 275 | static void |
278 | mysql_plugin_estimate_size (void *cls, | 276 | mysql_plugin_estimate_size(void *cls, |
279 | unsigned long long *estimate) | 277 | unsigned long long *estimate) |
280 | { | 278 | { |
281 | struct Plugin *plugin = cls; | 279 | struct Plugin *plugin = cls; |
282 | uint64_t total; | 280 | uint64_t total; |
@@ -285,29 +283,29 @@ mysql_plugin_estimate_size (void *cls, | |||
285 | GNUNET_MY_query_param_end | 283 | GNUNET_MY_query_param_end |
286 | }; | 284 | }; |
287 | struct GNUNET_MY_ResultSpec results_get[] = { | 285 | struct GNUNET_MY_ResultSpec results_get[] = { |
288 | GNUNET_MY_result_spec_uint64 (&total), | 286 | GNUNET_MY_result_spec_uint64(&total), |
289 | GNUNET_MY_result_spec_end | 287 | GNUNET_MY_result_spec_end |
290 | }; | 288 | }; |
291 | 289 | ||
292 | ret = GNUNET_MY_exec_prepared (plugin->mc, | 290 | ret = GNUNET_MY_exec_prepared(plugin->mc, |
293 | plugin->get_size, | 291 | plugin->get_size, |
294 | params_get); | 292 | params_get); |
295 | *estimate = 0; | 293 | *estimate = 0; |
296 | total = UINT64_MAX; | 294 | total = UINT64_MAX; |
297 | if ( (GNUNET_OK == ret) && | 295 | if ((GNUNET_OK == ret) && |
298 | (GNUNET_OK == | 296 | (GNUNET_OK == |
299 | GNUNET_MY_extract_result (plugin->get_size, | 297 | GNUNET_MY_extract_result(plugin->get_size, |
300 | results_get)) ) | 298 | results_get))) |
301 | { | 299 | { |
302 | *estimate = (unsigned long long) total; | 300 | *estimate = (unsigned long long)total; |
303 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 301 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
304 | "Size estimate for MySQL payload is %lld\n", | 302 | "Size estimate for MySQL payload is %lld\n", |
305 | (long long) total); | 303 | (long long)total); |
306 | GNUNET_assert (UINT64_MAX != total); | 304 | GNUNET_assert(UINT64_MAX != total); |
307 | GNUNET_break (GNUNET_NO == | 305 | GNUNET_break(GNUNET_NO == |
308 | GNUNET_MY_extract_result (plugin->get_size, | 306 | GNUNET_MY_extract_result(plugin->get_size, |
309 | NULL)); | 307 | NULL)); |
310 | } | 308 | } |
311 | } | 309 | } |
312 | 310 | ||
313 | 311 | ||
@@ -328,116 +326,116 @@ mysql_plugin_estimate_size (void *cls, | |||
328 | * @param cont_cls closure for @a cont | 326 | * @param cont_cls closure for @a cont |
329 | */ | 327 | */ |
330 | static void | 328 | static void |
331 | mysql_plugin_put (void *cls, | 329 | mysql_plugin_put(void *cls, |
332 | const struct GNUNET_HashCode *key, | 330 | const struct GNUNET_HashCode *key, |
333 | bool absent, | 331 | bool absent, |
334 | uint32_t size, | 332 | uint32_t size, |
335 | const void *data, | 333 | const void *data, |
336 | enum GNUNET_BLOCK_Type type, | 334 | enum GNUNET_BLOCK_Type type, |
337 | uint32_t priority, | 335 | uint32_t priority, |
338 | uint32_t anonymity, | 336 | uint32_t anonymity, |
339 | uint32_t replication, | 337 | uint32_t replication, |
340 | struct GNUNET_TIME_Absolute expiration, | 338 | struct GNUNET_TIME_Absolute expiration, |
341 | PluginPutCont cont, | 339 | PluginPutCont cont, |
342 | void *cont_cls) | 340 | void *cont_cls) |
343 | { | 341 | { |
344 | struct Plugin *plugin = cls; | 342 | struct Plugin *plugin = cls; |
345 | uint64_t lexpiration = expiration.abs_value_us; | 343 | uint64_t lexpiration = expiration.abs_value_us; |
346 | struct GNUNET_HashCode vhash; | 344 | struct GNUNET_HashCode vhash; |
347 | 345 | ||
348 | GNUNET_CRYPTO_hash (data, | 346 | GNUNET_CRYPTO_hash(data, |
349 | size, | 347 | size, |
350 | &vhash); | 348 | &vhash); |
351 | if (!absent) | 349 | if (!absent) |
352 | { | ||
353 | struct GNUNET_MY_QueryParam params_update[] = { | ||
354 | GNUNET_MY_query_param_uint32 (&priority), | ||
355 | GNUNET_MY_query_param_uint32 (&replication), | ||
356 | GNUNET_MY_query_param_uint64 (&lexpiration), | ||
357 | GNUNET_MY_query_param_auto_from_type (key), | ||
358 | GNUNET_MY_query_param_auto_from_type (&vhash), | ||
359 | GNUNET_MY_query_param_end | ||
360 | }; | ||
361 | |||
362 | if (GNUNET_OK != | ||
363 | GNUNET_MY_exec_prepared (plugin->mc, | ||
364 | plugin->update_entry, | ||
365 | params_update)) | ||
366 | { | 350 | { |
367 | cont (cont_cls, | 351 | struct GNUNET_MY_QueryParam params_update[] = { |
368 | key, | 352 | GNUNET_MY_query_param_uint32(&priority), |
369 | size, | 353 | GNUNET_MY_query_param_uint32(&replication), |
370 | GNUNET_SYSERR, | 354 | GNUNET_MY_query_param_uint64(&lexpiration), |
371 | _("MySQL statement run failure")); | 355 | GNUNET_MY_query_param_auto_from_type(key), |
372 | return; | 356 | GNUNET_MY_query_param_auto_from_type(&vhash), |
373 | } | 357 | GNUNET_MY_query_param_end |
374 | 358 | }; | |
375 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt (plugin->update_entry); | 359 | |
376 | my_ulonglong rows = mysql_stmt_affected_rows (stmt); | 360 | if (GNUNET_OK != |
377 | 361 | GNUNET_MY_exec_prepared(plugin->mc, | |
378 | GNUNET_break (GNUNET_NO == | 362 | plugin->update_entry, |
379 | GNUNET_MY_extract_result (plugin->update_entry, | 363 | params_update)) |
364 | { | ||
365 | cont(cont_cls, | ||
366 | key, | ||
367 | size, | ||
368 | GNUNET_SYSERR, | ||
369 | _("MySQL statement run failure")); | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt(plugin->update_entry); | ||
374 | my_ulonglong rows = mysql_stmt_affected_rows(stmt); | ||
375 | |||
376 | GNUNET_break(GNUNET_NO == | ||
377 | GNUNET_MY_extract_result(plugin->update_entry, | ||
380 | NULL)); | 378 | NULL)); |
381 | if (0 != rows) | 379 | if (0 != rows) |
382 | { | 380 | { |
383 | cont (cont_cls, | 381 | cont(cont_cls, |
384 | key, | 382 | key, |
385 | size, | 383 | size, |
386 | GNUNET_NO, | 384 | GNUNET_NO, |
387 | NULL); | 385 | NULL); |
388 | return; | 386 | return; |
387 | } | ||
389 | } | 388 | } |
390 | } | ||
391 | 389 | ||
392 | uint64_t lrvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 390 | uint64_t lrvalue = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, |
393 | UINT64_MAX); | 391 | UINT64_MAX); |
394 | struct GNUNET_MY_QueryParam params_insert[] = { | 392 | struct GNUNET_MY_QueryParam params_insert[] = { |
395 | GNUNET_MY_query_param_uint32 (&replication), | 393 | GNUNET_MY_query_param_uint32(&replication), |
396 | GNUNET_MY_query_param_uint32 (&type), | 394 | GNUNET_MY_query_param_uint32(&type), |
397 | GNUNET_MY_query_param_uint32 (&priority), | 395 | GNUNET_MY_query_param_uint32(&priority), |
398 | GNUNET_MY_query_param_uint32 (&anonymity), | 396 | GNUNET_MY_query_param_uint32(&anonymity), |
399 | GNUNET_MY_query_param_uint64 (&lexpiration), | 397 | GNUNET_MY_query_param_uint64(&lexpiration), |
400 | GNUNET_MY_query_param_uint64 (&lrvalue), | 398 | GNUNET_MY_query_param_uint64(&lrvalue), |
401 | GNUNET_MY_query_param_auto_from_type (key), | 399 | GNUNET_MY_query_param_auto_from_type(key), |
402 | GNUNET_MY_query_param_auto_from_type (&vhash), | 400 | GNUNET_MY_query_param_auto_from_type(&vhash), |
403 | GNUNET_MY_query_param_fixed_size (data, size), | 401 | GNUNET_MY_query_param_fixed_size(data, size), |
404 | GNUNET_MY_query_param_end | 402 | GNUNET_MY_query_param_end |
405 | }; | 403 | }; |
406 | 404 | ||
407 | if (size > MAX_DATUM_SIZE) | 405 | if (size > MAX_DATUM_SIZE) |
408 | { | 406 | { |
409 | GNUNET_break (0); | 407 | GNUNET_break(0); |
410 | cont (cont_cls, key, size, GNUNET_SYSERR, _("Data too large")); | 408 | cont(cont_cls, key, size, GNUNET_SYSERR, _("Data too large")); |
411 | return; | 409 | return; |
412 | } | 410 | } |
413 | 411 | ||
414 | if (GNUNET_OK != | 412 | if (GNUNET_OK != |
415 | GNUNET_MY_exec_prepared (plugin->mc, | 413 | GNUNET_MY_exec_prepared(plugin->mc, |
416 | plugin->insert_entry, | 414 | plugin->insert_entry, |
417 | params_insert)) | 415 | params_insert)) |
418 | { | 416 | { |
419 | cont (cont_cls, | 417 | cont(cont_cls, |
420 | key, | 418 | key, |
421 | size, | 419 | size, |
422 | GNUNET_SYSERR, | 420 | GNUNET_SYSERR, |
423 | _("MySQL statement run failure")); | 421 | _("MySQL statement run failure")); |
424 | return; | 422 | return; |
425 | } | 423 | } |
426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
427 | "Inserted value `%s' with size %u into gn090 table\n", | 425 | "Inserted value `%s' with size %u into gn090 table\n", |
428 | GNUNET_h2s (key), | 426 | GNUNET_h2s(key), |
429 | (unsigned int) size); | 427 | (unsigned int)size); |
430 | if (size > 0) | 428 | if (size > 0) |
431 | plugin->env->duc (plugin->env->cls, | 429 | plugin->env->duc(plugin->env->cls, |
432 | size); | 430 | size); |
433 | GNUNET_break (GNUNET_NO == | 431 | GNUNET_break(GNUNET_NO == |
434 | GNUNET_MY_extract_result (plugin->insert_entry, | 432 | GNUNET_MY_extract_result(plugin->insert_entry, |
435 | NULL)); | 433 | NULL)); |
436 | cont (cont_cls, | 434 | cont(cont_cls, |
437 | key, | 435 | key, |
438 | size, | 436 | size, |
439 | GNUNET_OK, | 437 | GNUNET_OK, |
440 | NULL); | 438 | NULL); |
441 | } | 439 | } |
442 | 440 | ||
443 | 441 | ||
@@ -452,11 +450,11 @@ mysql_plugin_put (void *cls, | |||
452 | * @param params_select arguments to initialize stmt | 450 | * @param params_select arguments to initialize stmt |
453 | */ | 451 | */ |
454 | static void | 452 | static void |
455 | execute_select (struct Plugin *plugin, | 453 | execute_select(struct Plugin *plugin, |
456 | struct GNUNET_MYSQL_StatementHandle *stmt, | 454 | struct GNUNET_MYSQL_StatementHandle *stmt, |
457 | PluginDatumProcessor proc, | 455 | PluginDatumProcessor proc, |
458 | void *proc_cls, | 456 | void *proc_cls, |
459 | struct GNUNET_MY_QueryParam *params_select) | 457 | struct GNUNET_MY_QueryParam *params_select) |
460 | { | 458 | { |
461 | int ret; | 459 | int ret; |
462 | uint32_t replication; | 460 | uint32_t replication; |
@@ -469,65 +467,65 @@ execute_select (struct Plugin *plugin, | |||
469 | struct GNUNET_HashCode key; | 467 | struct GNUNET_HashCode key; |
470 | struct GNUNET_TIME_Absolute expiration; | 468 | struct GNUNET_TIME_Absolute expiration; |
471 | struct GNUNET_MY_ResultSpec results_select[] = { | 469 | struct GNUNET_MY_ResultSpec results_select[] = { |
472 | GNUNET_MY_result_spec_uint32 (&replication), | 470 | GNUNET_MY_result_spec_uint32(&replication), |
473 | GNUNET_MY_result_spec_uint32 (&type), | 471 | GNUNET_MY_result_spec_uint32(&type), |
474 | GNUNET_MY_result_spec_uint32 (&priority), | 472 | GNUNET_MY_result_spec_uint32(&priority), |
475 | GNUNET_MY_result_spec_uint32 (&anonymity), | 473 | GNUNET_MY_result_spec_uint32(&anonymity), |
476 | GNUNET_MY_result_spec_absolute_time (&expiration), | 474 | GNUNET_MY_result_spec_absolute_time(&expiration), |
477 | GNUNET_MY_result_spec_auto_from_type (&key), | 475 | GNUNET_MY_result_spec_auto_from_type(&key), |
478 | GNUNET_MY_result_spec_variable_size (&value, &value_size), | 476 | GNUNET_MY_result_spec_variable_size(&value, &value_size), |
479 | GNUNET_MY_result_spec_uint64 (&uid), | 477 | GNUNET_MY_result_spec_uint64(&uid), |
480 | GNUNET_MY_result_spec_end | 478 | GNUNET_MY_result_spec_end |
481 | }; | 479 | }; |
482 | 480 | ||
483 | ret = GNUNET_MY_exec_prepared (plugin->mc, | 481 | ret = GNUNET_MY_exec_prepared(plugin->mc, |
484 | stmt, | 482 | stmt, |
485 | params_select); | 483 | params_select); |
486 | if (GNUNET_OK != ret) | 484 | if (GNUNET_OK != ret) |
487 | { | 485 | { |
488 | proc (proc_cls, | 486 | proc(proc_cls, |
489 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 487 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
490 | return; | 488 | return; |
491 | } | 489 | } |
492 | 490 | ||
493 | ret = GNUNET_MY_extract_result (stmt, | 491 | ret = GNUNET_MY_extract_result(stmt, |
494 | results_select); | 492 | results_select); |
495 | if (GNUNET_OK != ret) | 493 | if (GNUNET_OK != ret) |
496 | { | 494 | { |
497 | proc (proc_cls, | 495 | proc(proc_cls, |
498 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 496 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
499 | return; | 497 | return; |
500 | } | 498 | } |
501 | 499 | ||
502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 500 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
503 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", | 501 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", |
504 | (unsigned int) value_size, | 502 | (unsigned int)value_size, |
505 | GNUNET_h2s (&key), | 503 | GNUNET_h2s(&key), |
506 | (unsigned int) priority, | 504 | (unsigned int)priority, |
507 | (unsigned int) anonymity, | 505 | (unsigned int)anonymity, |
508 | GNUNET_STRINGS_absolute_time_to_string (expiration)); | 506 | GNUNET_STRINGS_absolute_time_to_string(expiration)); |
509 | GNUNET_assert (value_size < MAX_DATUM_SIZE); | 507 | GNUNET_assert(value_size < MAX_DATUM_SIZE); |
510 | GNUNET_break (GNUNET_NO == | 508 | GNUNET_break(GNUNET_NO == |
511 | GNUNET_MY_extract_result (stmt, | 509 | GNUNET_MY_extract_result(stmt, |
512 | NULL)); | 510 | NULL)); |
513 | ret = proc (proc_cls, | 511 | ret = proc(proc_cls, |
514 | &key, | 512 | &key, |
515 | value_size, | 513 | value_size, |
516 | value, | 514 | value, |
517 | type, | 515 | type, |
518 | priority, | 516 | priority, |
519 | anonymity, | 517 | anonymity, |
520 | replication, | 518 | replication, |
521 | expiration, | 519 | expiration, |
522 | uid); | 520 | uid); |
523 | GNUNET_MY_cleanup_result (results_select); | 521 | GNUNET_MY_cleanup_result(results_select); |
524 | if (GNUNET_NO == ret) | 522 | if (GNUNET_NO == ret) |
525 | { | 523 | { |
526 | do_delete_entry (plugin, uid); | 524 | do_delete_entry(plugin, uid); |
527 | if (0 != value_size) | 525 | if (0 != value_size) |
528 | plugin->env->duc (plugin->env->cls, | 526 | plugin->env->duc(plugin->env->cls, |
529 | - value_size); | 527 | -value_size); |
530 | } | 528 | } |
531 | } | 529 | } |
532 | 530 | ||
533 | 531 | ||
@@ -545,74 +543,74 @@ execute_select (struct Plugin *plugin, | |||
545 | * @param proc_cls closure for @a proc | 543 | * @param proc_cls closure for @a proc |
546 | */ | 544 | */ |
547 | static void | 545 | static void |
548 | mysql_plugin_get_key (void *cls, | 546 | mysql_plugin_get_key(void *cls, |
549 | uint64_t next_uid, | 547 | uint64_t next_uid, |
550 | bool random, | 548 | bool random, |
551 | const struct GNUNET_HashCode *key, | 549 | const struct GNUNET_HashCode *key, |
552 | enum GNUNET_BLOCK_Type type, | 550 | enum GNUNET_BLOCK_Type type, |
553 | PluginDatumProcessor proc, | 551 | PluginDatumProcessor proc, |
554 | void *proc_cls) | 552 | void *proc_cls) |
555 | { | 553 | { |
556 | struct Plugin *plugin = cls; | 554 | struct Plugin *plugin = cls; |
557 | uint64_t rvalue; | 555 | uint64_t rvalue; |
558 | 556 | ||
559 | if (random) | 557 | if (random) |
560 | { | 558 | { |
561 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 559 | rvalue = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, |
562 | UINT64_MAX); | 560 | UINT64_MAX); |
563 | next_uid = 0; | 561 | next_uid = 0; |
564 | } | 562 | } |
565 | else | 563 | else |
566 | rvalue = 0; | 564 | rvalue = 0; |
567 | 565 | ||
568 | if (NULL == key) | 566 | if (NULL == key) |
569 | { | 567 | { |
570 | struct GNUNET_MY_QueryParam params_select[] = { | 568 | struct GNUNET_MY_QueryParam params_select[] = { |
571 | GNUNET_MY_query_param_uint64 (&next_uid), | 569 | GNUNET_MY_query_param_uint64(&next_uid), |
572 | GNUNET_MY_query_param_uint64 (&rvalue), | 570 | GNUNET_MY_query_param_uint64(&rvalue), |
573 | GNUNET_MY_query_param_uint64 (&rvalue), | 571 | GNUNET_MY_query_param_uint64(&rvalue), |
574 | GNUNET_MY_query_param_end | 572 | GNUNET_MY_query_param_end |
575 | }; | 573 | }; |
576 | 574 | ||
577 | execute_select (plugin, | 575 | execute_select(plugin, |
578 | plugin->select_entry, | 576 | plugin->select_entry, |
579 | proc, | 577 | proc, |
580 | proc_cls, | 578 | proc_cls, |
581 | params_select); | 579 | params_select); |
582 | } | 580 | } |
583 | else if (type != GNUNET_BLOCK_TYPE_ANY) | 581 | else if (type != GNUNET_BLOCK_TYPE_ANY) |
584 | { | 582 | { |
585 | struct GNUNET_MY_QueryParam params_select[] = { | 583 | struct GNUNET_MY_QueryParam params_select[] = { |
586 | GNUNET_MY_query_param_auto_from_type (key), | 584 | GNUNET_MY_query_param_auto_from_type(key), |
587 | GNUNET_MY_query_param_uint32 (&type), | 585 | GNUNET_MY_query_param_uint32(&type), |
588 | GNUNET_MY_query_param_uint64 (&next_uid), | 586 | GNUNET_MY_query_param_uint64(&next_uid), |
589 | GNUNET_MY_query_param_uint64 (&rvalue), | 587 | GNUNET_MY_query_param_uint64(&rvalue), |
590 | GNUNET_MY_query_param_uint64 (&rvalue), | 588 | GNUNET_MY_query_param_uint64(&rvalue), |
591 | GNUNET_MY_query_param_end | 589 | GNUNET_MY_query_param_end |
592 | }; | 590 | }; |
593 | 591 | ||
594 | execute_select (plugin, | 592 | execute_select(plugin, |
595 | plugin->select_entry_by_hash_and_type, | 593 | plugin->select_entry_by_hash_and_type, |
596 | proc, | 594 | proc, |
597 | proc_cls, | 595 | proc_cls, |
598 | params_select); | 596 | params_select); |
599 | } | 597 | } |
600 | else | 598 | else |
601 | { | 599 | { |
602 | struct GNUNET_MY_QueryParam params_select[] = { | 600 | struct GNUNET_MY_QueryParam params_select[] = { |
603 | GNUNET_MY_query_param_auto_from_type (key), | 601 | GNUNET_MY_query_param_auto_from_type(key), |
604 | GNUNET_MY_query_param_uint64 (&next_uid), | 602 | GNUNET_MY_query_param_uint64(&next_uid), |
605 | GNUNET_MY_query_param_uint64 (&rvalue), | 603 | GNUNET_MY_query_param_uint64(&rvalue), |
606 | GNUNET_MY_query_param_uint64 (&rvalue), | 604 | GNUNET_MY_query_param_uint64(&rvalue), |
607 | GNUNET_MY_query_param_end | 605 | GNUNET_MY_query_param_end |
608 | }; | 606 | }; |
609 | 607 | ||
610 | execute_select (plugin, | 608 | execute_select(plugin, |
611 | plugin->select_entry_by_hash, | 609 | plugin->select_entry_by_hash, |
612 | proc, | 610 | proc, |
613 | proc_cls, | 611 | proc_cls, |
614 | params_select); | 612 | params_select); |
615 | } | 613 | } |
616 | } | 614 | } |
617 | 615 | ||
618 | 616 | ||
@@ -628,35 +626,33 @@ mysql_plugin_get_key (void *cls, | |||
628 | * @param proc_cls closure for @a proc | 626 | * @param proc_cls closure for @a proc |
629 | */ | 627 | */ |
630 | static void | 628 | static void |
631 | mysql_plugin_get_zero_anonymity (void *cls, | 629 | mysql_plugin_get_zero_anonymity(void *cls, |
632 | uint64_t next_uid, | 630 | uint64_t next_uid, |
633 | enum GNUNET_BLOCK_Type type, | 631 | enum GNUNET_BLOCK_Type type, |
634 | PluginDatumProcessor proc, | 632 | PluginDatumProcessor proc, |
635 | void *proc_cls) | 633 | void *proc_cls) |
636 | { | 634 | { |
637 | struct Plugin *plugin = cls; | 635 | struct Plugin *plugin = cls; |
638 | uint32_t typei = (uint32_t) type; | 636 | uint32_t typei = (uint32_t)type; |
639 | 637 | ||
640 | struct GNUNET_MY_QueryParam params_zero_iter[] = { | 638 | struct GNUNET_MY_QueryParam params_zero_iter[] = { |
641 | GNUNET_MY_query_param_uint32 (&typei), | 639 | GNUNET_MY_query_param_uint32(&typei), |
642 | GNUNET_MY_query_param_uint64 (&next_uid), | 640 | GNUNET_MY_query_param_uint64(&next_uid), |
643 | GNUNET_MY_query_param_end | 641 | GNUNET_MY_query_param_end |
644 | }; | 642 | }; |
645 | 643 | ||
646 | execute_select (plugin, | 644 | execute_select(plugin, |
647 | plugin->zero_iter, | 645 | plugin->zero_iter, |
648 | proc, | 646 | proc, |
649 | proc_cls, | 647 | proc_cls, |
650 | params_zero_iter); | 648 | params_zero_iter); |
651 | } | 649 | } |
652 | 650 | ||
653 | 651 | ||
654 | /** | 652 | /** |
655 | * Context for #repl_proc() function. | 653 | * Context for #repl_proc() function. |
656 | */ | 654 | */ |
657 | struct ReplCtx | 655 | struct ReplCtx { |
658 | { | ||
659 | |||
660 | /** | 656 | /** |
661 | * Plugin handle. | 657 | * Plugin handle. |
662 | */ | 658 | */ |
@@ -695,49 +691,49 @@ struct ReplCtx | |||
695 | * #GNUNET_NO to delete the item and continue (if supported) | 691 | * #GNUNET_NO to delete the item and continue (if supported) |
696 | */ | 692 | */ |
697 | static int | 693 | static int |
698 | repl_proc (void *cls, | 694 | repl_proc(void *cls, |
699 | const struct GNUNET_HashCode *key, | 695 | const struct GNUNET_HashCode *key, |
700 | uint32_t size, | 696 | uint32_t size, |
701 | const void *data, | 697 | const void *data, |
702 | enum GNUNET_BLOCK_Type type, | 698 | enum GNUNET_BLOCK_Type type, |
703 | uint32_t priority, | 699 | uint32_t priority, |
704 | uint32_t anonymity, | 700 | uint32_t anonymity, |
705 | uint32_t replication, | 701 | uint32_t replication, |
706 | struct GNUNET_TIME_Absolute expiration, | 702 | struct GNUNET_TIME_Absolute expiration, |
707 | uint64_t uid) | 703 | uint64_t uid) |
708 | { | 704 | { |
709 | struct ReplCtx *rc = cls; | 705 | struct ReplCtx *rc = cls; |
710 | struct Plugin *plugin = rc->plugin; | 706 | struct Plugin *plugin = rc->plugin; |
711 | int ret; | 707 | int ret; |
712 | int iret; | 708 | int iret; |
713 | 709 | ||
714 | ret = rc->proc (rc->proc_cls, | 710 | ret = rc->proc(rc->proc_cls, |
715 | key, | 711 | key, |
716 | size, | 712 | size, |
717 | data, | 713 | data, |
718 | type, | 714 | type, |
719 | priority, | 715 | priority, |
720 | anonymity, | 716 | anonymity, |
721 | replication, | 717 | replication, |
722 | expiration, | 718 | expiration, |
723 | uid); | 719 | uid); |
724 | if (NULL != key) | 720 | if (NULL != key) |
725 | { | ||
726 | struct GNUNET_MY_QueryParam params_proc[] = { | ||
727 | GNUNET_MY_query_param_uint64 (&uid), | ||
728 | GNUNET_MY_query_param_end | ||
729 | }; | ||
730 | |||
731 | iret = GNUNET_MY_exec_prepared (plugin->mc, | ||
732 | plugin->dec_repl, | ||
733 | params_proc); | ||
734 | if (GNUNET_SYSERR == iret) | ||
735 | { | 721 | { |
736 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 722 | struct GNUNET_MY_QueryParam params_proc[] = { |
737 | "Failed to reduce replication counter\n"); | 723 | GNUNET_MY_query_param_uint64(&uid), |
738 | return GNUNET_SYSERR; | 724 | GNUNET_MY_query_param_end |
725 | }; | ||
726 | |||
727 | iret = GNUNET_MY_exec_prepared(plugin->mc, | ||
728 | plugin->dec_repl, | ||
729 | params_proc); | ||
730 | if (GNUNET_SYSERR == iret) | ||
731 | { | ||
732 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
733 | "Failed to reduce replication counter\n"); | ||
734 | return GNUNET_SYSERR; | ||
735 | } | ||
739 | } | 736 | } |
740 | } | ||
741 | return ret; | 737 | return ret; |
742 | } | 738 | } |
743 | 739 | ||
@@ -754,9 +750,9 @@ repl_proc (void *cls, | |||
754 | * @param proc_cls closure for @a proc | 750 | * @param proc_cls closure for @a proc |
755 | */ | 751 | */ |
756 | static void | 752 | static void |
757 | mysql_plugin_get_replication (void *cls, | 753 | mysql_plugin_get_replication(void *cls, |
758 | PluginDatumProcessor proc, | 754 | PluginDatumProcessor proc, |
759 | void *proc_cls) | 755 | void *proc_cls) |
760 | { | 756 | { |
761 | struct Plugin *plugin = cls; | 757 | struct Plugin *plugin = cls; |
762 | uint64_t rvalue; | 758 | uint64_t rvalue; |
@@ -766,14 +762,14 @@ mysql_plugin_get_replication (void *cls, | |||
766 | GNUNET_MY_query_param_end | 762 | GNUNET_MY_query_param_end |
767 | }; | 763 | }; |
768 | struct GNUNET_MY_ResultSpec results_get[] = { | 764 | struct GNUNET_MY_ResultSpec results_get[] = { |
769 | GNUNET_MY_result_spec_uint32 (&repl), | 765 | GNUNET_MY_result_spec_uint32(&repl), |
770 | GNUNET_MY_result_spec_end | 766 | GNUNET_MY_result_spec_end |
771 | }; | 767 | }; |
772 | struct GNUNET_MY_QueryParam params_select[] = { | 768 | struct GNUNET_MY_QueryParam params_select[] = { |
773 | GNUNET_MY_query_param_uint32 (&repl), | 769 | GNUNET_MY_query_param_uint32(&repl), |
774 | GNUNET_MY_query_param_uint64 (&rvalue), | 770 | GNUNET_MY_query_param_uint64(&rvalue), |
775 | GNUNET_MY_query_param_uint32 (&repl), | 771 | GNUNET_MY_query_param_uint32(&repl), |
776 | GNUNET_MY_query_param_uint64 (&rvalue), | 772 | GNUNET_MY_query_param_uint64(&rvalue), |
777 | GNUNET_MY_query_param_end | 773 | GNUNET_MY_query_param_end |
778 | }; | 774 | }; |
779 | 775 | ||
@@ -782,32 +778,32 @@ mysql_plugin_get_replication (void *cls, | |||
782 | rc.proc_cls = proc_cls; | 778 | rc.proc_cls = proc_cls; |
783 | 779 | ||
784 | if (1 != | 780 | if (1 != |
785 | GNUNET_MY_exec_prepared (plugin->mc, | 781 | GNUNET_MY_exec_prepared(plugin->mc, |
786 | plugin->max_repl, | 782 | plugin->max_repl, |
787 | params_get)) | 783 | params_get)) |
788 | { | 784 | { |
789 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 785 | proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
790 | return; | 786 | return; |
791 | } | 787 | } |
792 | 788 | ||
793 | if (GNUNET_OK != | 789 | if (GNUNET_OK != |
794 | GNUNET_MY_extract_result (plugin->max_repl, | 790 | GNUNET_MY_extract_result(plugin->max_repl, |
795 | results_get)) | 791 | results_get)) |
796 | { | 792 | { |
797 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 793 | proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
798 | return; | 794 | return; |
799 | } | 795 | } |
800 | GNUNET_break (GNUNET_NO == | 796 | GNUNET_break(GNUNET_NO == |
801 | GNUNET_MY_extract_result (plugin->max_repl, | 797 | GNUNET_MY_extract_result(plugin->max_repl, |
802 | NULL)); | 798 | NULL)); |
803 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 799 | rvalue = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, |
804 | UINT64_MAX); | 800 | UINT64_MAX); |
805 | 801 | ||
806 | execute_select (plugin, | 802 | execute_select(plugin, |
807 | plugin->select_replication, | 803 | plugin->select_replication, |
808 | &repl_proc, | 804 | &repl_proc, |
809 | &rc, | 805 | &rc, |
810 | params_select); | 806 | params_select); |
811 | } | 807 | } |
812 | 808 | ||
813 | 809 | ||
@@ -819,9 +815,9 @@ mysql_plugin_get_replication (void *cls, | |||
819 | * @param proc_cls closure for @a proc | 815 | * @param proc_cls closure for @a proc |
820 | */ | 816 | */ |
821 | static void | 817 | static void |
822 | mysql_plugin_get_keys (void *cls, | 818 | mysql_plugin_get_keys(void *cls, |
823 | PluginKeyProcessor proc, | 819 | PluginKeyProcessor proc, |
824 | void *proc_cls) | 820 | void *proc_cls) |
825 | { | 821 | { |
826 | struct Plugin *plugin = cls; | 822 | struct Plugin *plugin = cls; |
827 | int ret; | 823 | int ret; |
@@ -833,78 +829,76 @@ mysql_plugin_get_keys (void *cls, | |||
833 | GNUNET_MY_query_param_end | 829 | GNUNET_MY_query_param_end |
834 | }; | 830 | }; |
835 | struct GNUNET_MY_ResultSpec results_select[] = { | 831 | struct GNUNET_MY_ResultSpec results_select[] = { |
836 | GNUNET_MY_result_spec_auto_from_type (&key), | 832 | GNUNET_MY_result_spec_auto_from_type(&key), |
837 | GNUNET_MY_result_spec_end | 833 | GNUNET_MY_result_spec_end |
838 | }; | 834 | }; |
839 | 835 | ||
840 | GNUNET_assert (NULL != proc); | 836 | GNUNET_assert(NULL != proc); |
841 | statement = GNUNET_MYSQL_statement_get_stmt (plugin->get_all_keys); | 837 | statement = GNUNET_MYSQL_statement_get_stmt(plugin->get_all_keys); |
842 | if (GNUNET_OK != | 838 | if (GNUNET_OK != |
843 | GNUNET_MY_exec_prepared (plugin->mc, | 839 | GNUNET_MY_exec_prepared(plugin->mc, |
844 | plugin->get_all_keys, | 840 | plugin->get_all_keys, |
845 | params_select)) | 841 | params_select)) |
846 | { | 842 | { |
847 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 843 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
848 | _("`%s' for `%s' failed at %s:%d with error: %s\n"), | 844 | _("`%s' for `%s' failed at %s:%d with error: %s\n"), |
849 | "mysql_stmt_execute", | 845 | "mysql_stmt_execute", |
850 | GET_ALL_KEYS, | 846 | GET_ALL_KEYS, |
851 | __FILE__, | 847 | __FILE__, |
852 | __LINE__, | 848 | __LINE__, |
853 | mysql_stmt_error (statement)); | 849 | mysql_stmt_error(statement)); |
854 | GNUNET_MYSQL_statements_invalidate (plugin->mc); | 850 | GNUNET_MYSQL_statements_invalidate(plugin->mc); |
855 | proc (proc_cls, NULL, 0); | 851 | proc(proc_cls, NULL, 0); |
856 | return; | 852 | return; |
857 | } | 853 | } |
858 | memset (&last, 0, sizeof (last)); /* make static analysis happy */ | 854 | memset(&last, 0, sizeof(last)); /* make static analysis happy */ |
859 | ret = GNUNET_YES; | 855 | ret = GNUNET_YES; |
860 | cnt = 0; | 856 | cnt = 0; |
861 | while (ret == GNUNET_YES) | 857 | while (ret == GNUNET_YES) |
862 | { | ||
863 | ret = GNUNET_MY_extract_result (plugin->get_all_keys, | ||
864 | results_select); | ||
865 | if (0 != GNUNET_memcmp (&last, | ||
866 | &key)) | ||
867 | { | 858 | { |
868 | if (0 != cnt) | 859 | ret = GNUNET_MY_extract_result(plugin->get_all_keys, |
869 | proc (proc_cls, | 860 | results_select); |
870 | &last, | 861 | if (0 != GNUNET_memcmp(&last, |
871 | cnt); | 862 | &key)) |
872 | cnt = 1; | 863 | { |
873 | last = key; | 864 | if (0 != cnt) |
865 | proc(proc_cls, | ||
866 | &last, | ||
867 | cnt); | ||
868 | cnt = 1; | ||
869 | last = key; | ||
870 | } | ||
871 | else | ||
872 | { | ||
873 | cnt++; | ||
874 | } | ||
874 | } | 875 | } |
875 | else | ||
876 | { | ||
877 | cnt++; | ||
878 | } | ||
879 | } | ||
880 | if (0 != cnt) | 876 | if (0 != cnt) |
881 | proc (proc_cls, | 877 | proc(proc_cls, |
882 | &last, | 878 | &last, |
883 | cnt); | 879 | cnt); |
884 | /* finally, let app know we are done */ | 880 | /* finally, let app know we are done */ |
885 | proc (proc_cls, | 881 | proc(proc_cls, |
886 | NULL, | 882 | NULL, |
887 | 0); | 883 | 0); |
888 | if (GNUNET_SYSERR == ret) | 884 | if (GNUNET_SYSERR == ret) |
889 | { | 885 | { |
890 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 886 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
891 | _("`%s' failed at %s:%d with error: %s\n"), | 887 | _("`%s' failed at %s:%d with error: %s\n"), |
892 | "mysql_stmt_fetch", | 888 | "mysql_stmt_fetch", |
893 | __FILE__, | 889 | __FILE__, |
894 | __LINE__, | 890 | __LINE__, |
895 | mysql_stmt_error (statement)); | 891 | mysql_stmt_error(statement)); |
896 | GNUNET_MYSQL_statements_invalidate (plugin->mc); | 892 | GNUNET_MYSQL_statements_invalidate(plugin->mc); |
897 | return; | 893 | return; |
898 | } | 894 | } |
899 | } | 895 | } |
900 | 896 | ||
901 | 897 | ||
902 | /** | 898 | /** |
903 | * Context for #expi_proc() function. | 899 | * Context for #expi_proc() function. |
904 | */ | 900 | */ |
905 | struct ExpiCtx | 901 | struct ExpiCtx { |
906 | { | ||
907 | |||
908 | /** | 902 | /** |
909 | * Plugin handle. | 903 | * Plugin handle. |
910 | */ | 904 | */ |
@@ -944,16 +938,16 @@ struct ExpiCtx | |||
944 | * #GNUNET_NO to delete the item and continue (if supported) | 938 | * #GNUNET_NO to delete the item and continue (if supported) |
945 | */ | 939 | */ |
946 | static int | 940 | static int |
947 | expi_proc (void *cls, | 941 | expi_proc(void *cls, |
948 | const struct GNUNET_HashCode *key, | 942 | const struct GNUNET_HashCode *key, |
949 | uint32_t size, | 943 | uint32_t size, |
950 | const void *data, | 944 | const void *data, |
951 | enum GNUNET_BLOCK_Type type, | 945 | enum GNUNET_BLOCK_Type type, |
952 | uint32_t priority, | 946 | uint32_t priority, |
953 | uint32_t anonymity, | 947 | uint32_t anonymity, |
954 | uint32_t replication, | 948 | uint32_t replication, |
955 | struct GNUNET_TIME_Absolute expiration, | 949 | struct GNUNET_TIME_Absolute expiration, |
956 | uint64_t uid) | 950 | uint64_t uid) |
957 | { | 951 | { |
958 | struct ExpiCtx *rc = cls; | 952 | struct ExpiCtx *rc = cls; |
959 | struct Plugin *plugin = rc->plugin; | 953 | struct Plugin *plugin = rc->plugin; |
@@ -962,24 +956,24 @@ expi_proc (void *cls, | |||
962 | }; | 956 | }; |
963 | 957 | ||
964 | if (NULL == key) | 958 | if (NULL == key) |
965 | { | 959 | { |
966 | execute_select (plugin, | 960 | execute_select(plugin, |
967 | plugin->select_priority, | 961 | plugin->select_priority, |
968 | rc->proc, | 962 | rc->proc, |
969 | rc->proc_cls, | 963 | rc->proc_cls, |
970 | params_select); | 964 | params_select); |
971 | return GNUNET_SYSERR; | 965 | return GNUNET_SYSERR; |
972 | } | 966 | } |
973 | return rc->proc (rc->proc_cls, | 967 | return rc->proc(rc->proc_cls, |
974 | key, | 968 | key, |
975 | size, | 969 | size, |
976 | data, | 970 | data, |
977 | type, | 971 | type, |
978 | priority, | 972 | priority, |
979 | anonymity, | 973 | anonymity, |
980 | replication, | 974 | replication, |
981 | expiration, | 975 | expiration, |
982 | uid); | 976 | uid); |
983 | } | 977 | } |
984 | 978 | ||
985 | 979 | ||
@@ -992,14 +986,14 @@ expi_proc (void *cls, | |||
992 | * @param proc_cls closure for @a proc | 986 | * @param proc_cls closure for @a proc |
993 | */ | 987 | */ |
994 | static void | 988 | static void |
995 | mysql_plugin_get_expiration (void *cls, | 989 | mysql_plugin_get_expiration(void *cls, |
996 | PluginDatumProcessor proc, | 990 | PluginDatumProcessor proc, |
997 | void *proc_cls) | 991 | void *proc_cls) |
998 | { | 992 | { |
999 | struct Plugin *plugin = cls; | 993 | struct Plugin *plugin = cls; |
1000 | struct GNUNET_TIME_Absolute now; | 994 | struct GNUNET_TIME_Absolute now; |
1001 | struct GNUNET_MY_QueryParam params_select[] = { | 995 | struct GNUNET_MY_QueryParam params_select[] = { |
1002 | GNUNET_MY_query_param_absolute_time (&now), | 996 | GNUNET_MY_query_param_absolute_time(&now), |
1003 | GNUNET_MY_query_param_end | 997 | GNUNET_MY_query_param_end |
1004 | }; | 998 | }; |
1005 | struct ExpiCtx rc; | 999 | struct ExpiCtx rc; |
@@ -1007,12 +1001,12 @@ mysql_plugin_get_expiration (void *cls, | |||
1007 | rc.plugin = plugin; | 1001 | rc.plugin = plugin; |
1008 | rc.proc = proc; | 1002 | rc.proc = proc; |
1009 | rc.proc_cls = proc_cls; | 1003 | rc.proc_cls = proc_cls; |
1010 | now = GNUNET_TIME_absolute_get (); | 1004 | now = GNUNET_TIME_absolute_get(); |
1011 | execute_select (plugin, | 1005 | execute_select(plugin, |
1012 | plugin->select_expiration, | 1006 | plugin->select_expiration, |
1013 | expi_proc, | 1007 | expi_proc, |
1014 | &rc, | 1008 | &rc, |
1015 | params_select); | 1009 | params_select); |
1016 | } | 1010 | } |
1017 | 1011 | ||
1018 | 1012 | ||
@@ -1022,15 +1016,15 @@ mysql_plugin_get_expiration (void *cls, | |||
1022 | * @param cls the `struct Plugin *` | 1016 | * @param cls the `struct Plugin *` |
1023 | */ | 1017 | */ |
1024 | static void | 1018 | static void |
1025 | mysql_plugin_drop (void *cls) | 1019 | mysql_plugin_drop(void *cls) |
1026 | { | 1020 | { |
1027 | struct Plugin *plugin = cls; | 1021 | struct Plugin *plugin = cls; |
1028 | 1022 | ||
1029 | if (GNUNET_OK != | 1023 | if (GNUNET_OK != |
1030 | GNUNET_MYSQL_statement_run (plugin->mc, | 1024 | GNUNET_MYSQL_statement_run(plugin->mc, |
1031 | "DROP TABLE gn090")) | 1025 | "DROP TABLE gn090")) |
1032 | return; /* error */ | 1026 | return; /* error */ |
1033 | plugin->env->duc (plugin->env->cls, 0); | 1027 | plugin->env->duc(plugin->env->cls, 0); |
1034 | } | 1028 | } |
1035 | 1029 | ||
1036 | 1030 | ||
@@ -1045,55 +1039,55 @@ mysql_plugin_drop (void *cls) | |||
1045 | * @param cont_cls continuation closure for @a cont | 1039 | * @param cont_cls continuation closure for @a cont |
1046 | */ | 1040 | */ |
1047 | static void | 1041 | static void |
1048 | mysql_plugin_remove_key (void *cls, | 1042 | mysql_plugin_remove_key(void *cls, |
1049 | const struct GNUNET_HashCode *key, | 1043 | const struct GNUNET_HashCode *key, |
1050 | uint32_t size, | 1044 | uint32_t size, |
1051 | const void *data, | 1045 | const void *data, |
1052 | PluginRemoveCont cont, | 1046 | PluginRemoveCont cont, |
1053 | void *cont_cls) | 1047 | void *cont_cls) |
1054 | { | 1048 | { |
1055 | struct Plugin *plugin = cls; | 1049 | struct Plugin *plugin = cls; |
1056 | struct GNUNET_MY_QueryParam params_delete[] = { | 1050 | struct GNUNET_MY_QueryParam params_delete[] = { |
1057 | GNUNET_MY_query_param_auto_from_type (key), | 1051 | GNUNET_MY_query_param_auto_from_type(key), |
1058 | GNUNET_MY_query_param_fixed_size (data, size), | 1052 | GNUNET_MY_query_param_fixed_size(data, size), |
1059 | GNUNET_MY_query_param_end | 1053 | GNUNET_MY_query_param_end |
1060 | }; | 1054 | }; |
1061 | 1055 | ||
1062 | if (GNUNET_OK != | 1056 | if (GNUNET_OK != |
1063 | GNUNET_MY_exec_prepared (plugin->mc, | 1057 | GNUNET_MY_exec_prepared(plugin->mc, |
1064 | plugin->delete_entry_by_hash_value, | 1058 | plugin->delete_entry_by_hash_value, |
1065 | params_delete)) | 1059 | params_delete)) |
1066 | { | 1060 | { |
1067 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1061 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1068 | "Removing key `%s' from gn090 table failed\n", | 1062 | "Removing key `%s' from gn090 table failed\n", |
1069 | GNUNET_h2s (key)); | 1063 | GNUNET_h2s(key)); |
1070 | cont (cont_cls, | 1064 | cont(cont_cls, |
1071 | key, | 1065 | key, |
1072 | size, | 1066 | size, |
1073 | GNUNET_SYSERR, | 1067 | GNUNET_SYSERR, |
1074 | _("MySQL statement run failure")); | 1068 | _("MySQL statement run failure")); |
1075 | return; | 1069 | return; |
1076 | } | 1070 | } |
1077 | 1071 | ||
1078 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt (plugin->delete_entry_by_hash_value); | 1072 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt(plugin->delete_entry_by_hash_value); |
1079 | my_ulonglong rows = mysql_stmt_affected_rows (stmt); | 1073 | my_ulonglong rows = mysql_stmt_affected_rows(stmt); |
1080 | 1074 | ||
1081 | if (0 == rows) | 1075 | if (0 == rows) |
1082 | { | 1076 | { |
1083 | cont (cont_cls, | 1077 | cont(cont_cls, |
1084 | key, | 1078 | key, |
1085 | size, | 1079 | size, |
1086 | GNUNET_NO, | 1080 | GNUNET_NO, |
1087 | NULL); | 1081 | NULL); |
1088 | return; | 1082 | return; |
1089 | } | 1083 | } |
1090 | plugin->env->duc (plugin->env->cls, | 1084 | plugin->env->duc(plugin->env->cls, |
1091 | -size); | 1085 | -size); |
1092 | cont (cont_cls, | 1086 | cont(cont_cls, |
1093 | key, | 1087 | key, |
1094 | size, | 1088 | size, |
1095 | GNUNET_OK, | 1089 | GNUNET_OK, |
1096 | NULL); | 1090 | NULL); |
1097 | } | 1091 | } |
1098 | 1092 | ||
1099 | 1093 | ||
@@ -1104,67 +1098,67 @@ mysql_plugin_remove_key (void *cls, | |||
1104 | * @return our `struct Plugin *` | 1098 | * @return our `struct Plugin *` |
1105 | */ | 1099 | */ |
1106 | void * | 1100 | void * |
1107 | libgnunet_plugin_datastore_mysql_init (void *cls) | 1101 | libgnunet_plugin_datastore_mysql_init(void *cls) |
1108 | { | 1102 | { |
1109 | struct GNUNET_DATASTORE_PluginEnvironment *env = cls; | 1103 | struct GNUNET_DATASTORE_PluginEnvironment *env = cls; |
1110 | struct GNUNET_DATASTORE_PluginFunctions *api; | 1104 | struct GNUNET_DATASTORE_PluginFunctions *api; |
1111 | struct Plugin *plugin; | 1105 | struct Plugin *plugin; |
1112 | 1106 | ||
1113 | plugin = GNUNET_new (struct Plugin); | 1107 | plugin = GNUNET_new(struct Plugin); |
1114 | plugin->env = env; | 1108 | plugin->env = env; |
1115 | plugin->mc = GNUNET_MYSQL_context_create (env->cfg, | 1109 | plugin->mc = GNUNET_MYSQL_context_create(env->cfg, |
1116 | "datastore-mysql"); | 1110 | "datastore-mysql"); |
1117 | if (NULL == plugin->mc) | 1111 | if (NULL == plugin->mc) |
1118 | { | 1112 | { |
1119 | GNUNET_free (plugin); | 1113 | GNUNET_free(plugin); |
1120 | return NULL; | 1114 | return NULL; |
1121 | } | 1115 | } |
1122 | #define MRUNS(a) (GNUNET_OK != GNUNET_MYSQL_statement_run (plugin->mc, a) ) | 1116 | #define MRUNS(a) (GNUNET_OK != GNUNET_MYSQL_statement_run(plugin->mc, a)) |
1123 | #define PINIT(a,b) (NULL == (a = GNUNET_MYSQL_statement_prepare (plugin->mc, b))) | 1117 | #define PINIT(a, b) (NULL == (a = GNUNET_MYSQL_statement_prepare(plugin->mc, b))) |
1124 | if (MRUNS | 1118 | if (MRUNS |
1125 | ("CREATE TABLE IF NOT EXISTS gn090 (" | 1119 | ("CREATE TABLE IF NOT EXISTS gn090 (" |
1126 | " repl INT(11) UNSIGNED NOT NULL DEFAULT 0," | 1120 | " repl INT(11) UNSIGNED NOT NULL DEFAULT 0," |
1127 | " type INT(11) UNSIGNED NOT NULL DEFAULT 0," | 1121 | " type INT(11) UNSIGNED NOT NULL DEFAULT 0," |
1128 | " prio INT(11) UNSIGNED NOT NULL DEFAULT 0," | 1122 | " prio INT(11) UNSIGNED NOT NULL DEFAULT 0," |
1129 | " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0," | 1123 | " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0," |
1130 | " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," | 1124 | " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," |
1131 | " rvalue BIGINT UNSIGNED NOT NULL," | 1125 | " rvalue BIGINT UNSIGNED NOT NULL," |
1132 | " hash BINARY(64) NOT NULL DEFAULT ''," | 1126 | " hash BINARY(64) NOT NULL DEFAULT ''," |
1133 | " vhash BINARY(64) NOT NULL DEFAULT ''," | 1127 | " vhash BINARY(64) NOT NULL DEFAULT ''," |
1134 | " value BLOB NOT NULL DEFAULT ''," " uid BIGINT NOT NULL AUTO_INCREMENT," | 1128 | " value BLOB NOT NULL DEFAULT ''," " uid BIGINT NOT NULL AUTO_INCREMENT," |
1135 | " PRIMARY KEY (uid)," | 1129 | " PRIMARY KEY (uid)," |
1136 | " INDEX idx_hash_type_uid (hash(64),type,rvalue)," | 1130 | " INDEX idx_hash_type_uid (hash(64),type,rvalue)," |
1137 | " INDEX idx_prio (prio)," | 1131 | " INDEX idx_prio (prio)," |
1138 | " INDEX idx_repl_rvalue (repl,rvalue)," | 1132 | " INDEX idx_repl_rvalue (repl,rvalue)," |
1139 | " INDEX idx_expire (expire)," | 1133 | " INDEX idx_expire (expire)," |
1140 | " INDEX idx_anonLevel_type_rvalue (anonLevel,type,rvalue)" | 1134 | " INDEX idx_anonLevel_type_rvalue (anonLevel,type,rvalue)" |
1141 | ") ENGINE=InnoDB") || MRUNS ("SET AUTOCOMMIT = 1") || | 1135 | ") ENGINE=InnoDB") || MRUNS("SET AUTOCOMMIT = 1") || |
1142 | PINIT (plugin->insert_entry, INSERT_ENTRY) || | 1136 | PINIT(plugin->insert_entry, INSERT_ENTRY) || |
1143 | PINIT (plugin->delete_entry_by_uid, DELETE_ENTRY_BY_UID) || | 1137 | PINIT(plugin->delete_entry_by_uid, DELETE_ENTRY_BY_UID) || |
1144 | PINIT (plugin->delete_entry_by_hash_value, DELETE_ENTRY_BY_HASH_VALUE) || | 1138 | PINIT(plugin->delete_entry_by_hash_value, DELETE_ENTRY_BY_HASH_VALUE) || |
1145 | PINIT (plugin->select_entry, SELECT_ENTRY) || | 1139 | PINIT(plugin->select_entry, SELECT_ENTRY) || |
1146 | PINIT (plugin->select_entry_by_hash, SELECT_ENTRY_BY_HASH) || | 1140 | PINIT(plugin->select_entry_by_hash, SELECT_ENTRY_BY_HASH) || |
1147 | PINIT (plugin->select_entry_by_hash_and_type, | 1141 | PINIT(plugin->select_entry_by_hash_and_type, |
1148 | SELECT_ENTRY_BY_HASH_AND_TYPE) || | 1142 | SELECT_ENTRY_BY_HASH_AND_TYPE) || |
1149 | PINIT (plugin->get_size, SELECT_SIZE) || | 1143 | PINIT(plugin->get_size, SELECT_SIZE) || |
1150 | PINIT (plugin->update_entry, UPDATE_ENTRY) || | 1144 | PINIT(plugin->update_entry, UPDATE_ENTRY) || |
1151 | PINIT (plugin->dec_repl, DEC_REPL) || | 1145 | PINIT(plugin->dec_repl, DEC_REPL) || |
1152 | PINIT (plugin->zero_iter, SELECT_IT_NON_ANONYMOUS) || | 1146 | PINIT(plugin->zero_iter, SELECT_IT_NON_ANONYMOUS) || |
1153 | PINIT (plugin->select_expiration, SELECT_IT_EXPIRATION) || | 1147 | PINIT(plugin->select_expiration, SELECT_IT_EXPIRATION) || |
1154 | PINIT (plugin->select_priority, SELECT_IT_PRIORITY) || | 1148 | PINIT(plugin->select_priority, SELECT_IT_PRIORITY) || |
1155 | PINIT (plugin->max_repl, SELECT_MAX_REPL) || | 1149 | PINIT(plugin->max_repl, SELECT_MAX_REPL) || |
1156 | PINIT (plugin->get_all_keys, GET_ALL_KEYS) || | 1150 | PINIT(plugin->get_all_keys, GET_ALL_KEYS) || |
1157 | PINIT (plugin->select_replication, SELECT_IT_REPLICATION) || | 1151 | PINIT(plugin->select_replication, SELECT_IT_REPLICATION) || |
1158 | false) | 1152 | false) |
1159 | { | 1153 | { |
1160 | GNUNET_MYSQL_context_destroy (plugin->mc); | 1154 | GNUNET_MYSQL_context_destroy(plugin->mc); |
1161 | GNUNET_free (plugin); | 1155 | GNUNET_free(plugin); |
1162 | return NULL; | 1156 | return NULL; |
1163 | } | 1157 | } |
1164 | #undef PINIT | 1158 | #undef PINIT |
1165 | #undef MRUNS | 1159 | #undef MRUNS |
1166 | 1160 | ||
1167 | api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); | 1161 | api = GNUNET_new(struct GNUNET_DATASTORE_PluginFunctions); |
1168 | api->cls = plugin; | 1162 | api->cls = plugin; |
1169 | api->estimate_size = &mysql_plugin_estimate_size; | 1163 | api->estimate_size = &mysql_plugin_estimate_size; |
1170 | api->put = &mysql_plugin_put; | 1164 | api->put = &mysql_plugin_put; |
@@ -1175,8 +1169,8 @@ libgnunet_plugin_datastore_mysql_init (void *cls) | |||
1175 | api->get_keys = &mysql_plugin_get_keys; | 1169 | api->get_keys = &mysql_plugin_get_keys; |
1176 | api->drop = &mysql_plugin_drop; | 1170 | api->drop = &mysql_plugin_drop; |
1177 | api->remove_key = &mysql_plugin_remove_key; | 1171 | api->remove_key = &mysql_plugin_remove_key; |
1178 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql", | 1172 | GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, "mysql", |
1179 | _("Mysql database running\n")); | 1173 | _("Mysql database running\n")); |
1180 | return api; | 1174 | return api; |
1181 | } | 1175 | } |
1182 | 1176 | ||
@@ -1188,14 +1182,14 @@ libgnunet_plugin_datastore_mysql_init (void *cls) | |||
1188 | * @return always NULL | 1182 | * @return always NULL |
1189 | */ | 1183 | */ |
1190 | void * | 1184 | void * |
1191 | libgnunet_plugin_datastore_mysql_done (void *cls) | 1185 | libgnunet_plugin_datastore_mysql_done(void *cls) |
1192 | { | 1186 | { |
1193 | struct GNUNET_DATASTORE_PluginFunctions *api = cls; | 1187 | struct GNUNET_DATASTORE_PluginFunctions *api = cls; |
1194 | struct Plugin *plugin = api->cls; | 1188 | struct Plugin *plugin = api->cls; |
1195 | 1189 | ||
1196 | GNUNET_MYSQL_context_destroy (plugin->mc); | 1190 | GNUNET_MYSQL_context_destroy(plugin->mc); |
1197 | GNUNET_free (plugin); | 1191 | GNUNET_free(plugin); |
1198 | GNUNET_free (api); | 1192 | GNUNET_free(api); |
1199 | return NULL; | 1193 | return NULL; |
1200 | } | 1194 | } |
1201 | 1195 | ||