diff options
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 34 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 16 |
2 files changed, 46 insertions, 4 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index e3f0dcb24..1e293a4ba 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -423,6 +423,8 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) | |||
423 | { | 423 | { |
424 | struct GNUNET_DATACACHE_PluginFunctions *api = cls; | 424 | struct GNUNET_DATACACHE_PluginFunctions *api = cls; |
425 | struct Plugin *plugin = api->cls; | 425 | struct Plugin *plugin = api->cls; |
426 | int result; | ||
427 | sqlite3_stmt *stmt; | ||
426 | 428 | ||
427 | #if !WINDOWS || defined(__CYGWIN__) | 429 | #if !WINDOWS || defined(__CYGWIN__) |
428 | if (0 != UNLINK (plugin->fn)) | 430 | if (0 != UNLINK (plugin->fn)) |
@@ -431,7 +433,37 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) | |||
431 | plugin->fn); | 433 | plugin->fn); |
432 | GNUNET_free (plugin->fn); | 434 | GNUNET_free (plugin->fn); |
433 | #endif | 435 | #endif |
434 | sqlite3_close (plugin->dbh); | 436 | result = sqlite3_close (plugin->dbh); |
437 | #if SQLITE_VERSION_NUMBER >= 3007000 | ||
438 | if (result == SQLITE_BUSY) | ||
439 | { | ||
440 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, | ||
441 | "sqlite", | ||
442 | _("Tried to close sqlite without finalizing all prepared statements.\n")); | ||
443 | stmt = sqlite3_next_stmt(plugin->dbh, NULL); | ||
444 | while (stmt != NULL) | ||
445 | { | ||
446 | #if DEBUG_SQLITE | ||
447 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | ||
448 | "sqlite", "Closing statement %p\n", stmt); | ||
449 | #endif | ||
450 | result = sqlite3_finalize(stmt); | ||
451 | #if DEBUG_SQLITE | ||
452 | if (result != SQLITE_OK) | ||
453 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | ||
454 | "sqlite", | ||
455 | "Failed to close statement %p: %d\n", stmt, result); | ||
456 | #endif | ||
457 | stmt = sqlite3_next_stmt(plugin->dbh, NULL); | ||
458 | } | ||
459 | result = sqlite3_close(plugin->dbh); | ||
460 | } | ||
461 | #endif | ||
462 | if (SQLITE_OK != result) | ||
463 | LOG_SQLITE (plugin->dbh, | ||
464 | GNUNET_ERROR_TYPE_ERROR, | ||
465 | "sqlite3_close"); | ||
466 | |||
435 | #if WINDOWS && !defined(__CYGWIN__) | 467 | #if WINDOWS && !defined(__CYGWIN__) |
436 | if (0 != UNLINK (plugin->fn)) | 468 | if (0 != UNLINK (plugin->fn)) |
437 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 469 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 1b8382537..1f7348a98 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -359,6 +359,8 @@ static void | |||
359 | database_shutdown (struct Plugin *plugin) | 359 | database_shutdown (struct Plugin *plugin) |
360 | { | 360 | { |
361 | int result; | 361 | int result; |
362 | sqlite3_stmt *stmt; | ||
363 | |||
362 | if (plugin->delRow != NULL) | 364 | if (plugin->delRow != NULL) |
363 | sqlite3_finalize (plugin->delRow); | 365 | sqlite3_finalize (plugin->delRow); |
364 | if (plugin->updPrio != NULL) | 366 | if (plugin->updPrio != NULL) |
@@ -366,13 +368,14 @@ database_shutdown (struct Plugin *plugin) | |||
366 | if (plugin->insertContent != NULL) | 368 | if (plugin->insertContent != NULL) |
367 | sqlite3_finalize (plugin->insertContent); | 369 | sqlite3_finalize (plugin->insertContent); |
368 | result = sqlite3_close(plugin->dbh); | 370 | result = sqlite3_close(plugin->dbh); |
369 | while (result == SQLITE_BUSY) | 371 | #if SQLITE_VERSION_NUMBER >= 3007000 |
372 | if (result == SQLITE_BUSY) | ||
370 | { | 373 | { |
371 | sqlite3_stmt *stmt; | ||
372 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, | 374 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
373 | "sqlite", | 375 | "sqlite", |
374 | _("Tried to close sqlite without finalizing all prepared statements.\n")); | 376 | _("Tried to close sqlite without finalizing all prepared statements.\n")); |
375 | for (stmt = sqlite3_next_stmt(plugin->dbh, NULL); stmt != NULL; stmt = sqlite3_next_stmt(plugin->dbh, NULL)) | 377 | stmt = sqlite3_next_stmt(plugin->dbh, NULL); |
378 | while (stmt != NULL) | ||
376 | { | 379 | { |
377 | #if DEBUG_SQLITE | 380 | #if DEBUG_SQLITE |
378 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 381 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
@@ -385,9 +388,16 @@ database_shutdown (struct Plugin *plugin) | |||
385 | "sqlite", | 388 | "sqlite", |
386 | "Failed to close statement %p: %d\n", stmt, result); | 389 | "Failed to close statement %p: %d\n", stmt, result); |
387 | #endif | 390 | #endif |
391 | stmt = sqlite3_next_stmt(plugin->dbh, NULL); | ||
388 | } | 392 | } |
389 | result = sqlite3_close(plugin->dbh); | 393 | result = sqlite3_close(plugin->dbh); |
390 | } | 394 | } |
395 | #endif | ||
396 | if (SQLITE_OK != result) | ||
397 | LOG_SQLITE (plugin, NULL, | ||
398 | GNUNET_ERROR_TYPE_ERROR, | ||
399 | "sqlite3_close"); | ||
400 | |||
391 | GNUNET_free_non_null (plugin->fn); | 401 | GNUNET_free_non_null (plugin->fn); |
392 | } | 402 | } |
393 | 403 | ||